Appends household or housing variables from a household-level source to a
person-level ENEMDU source using a controlled household-key match. This
function only joins source variables. It does not derive IPM components, does
not compute ipm_score, tpm, tpem, A, or ipm, and does not validate
official IPM reproducibility.
Usage
enemdu_join_ipm_sources(
data,
household_data,
household_id = "id_hogar",
housing_vars = NULL,
overwrite = FALSE,
strict = TRUE
)Arguments
- data
Person-level ENEMDU data.
- household_data
Household- or housing-level ENEMDU data.
- household_id
Household identifier used in both sources.
- housing_vars
Household or housing variables to append from
household_data. IfNULL, the default IPM source variable set is used.- overwrite
Logical. If
TRUE, replace existinghousing_varsindata.- strict
Logical. If
TRUE, abort when a non-missing household indatahas no match inhousehold_data. IfFALSE, unmatched person rows are preserved and receiveNAhousing values.
Value
A data frame with appended household or housing variables and an
ipm_source_join_diagnostics attribute.
Details
The output is intended to prepare person-level data for a future
enemdu_build_ipm_components() implementation.
Examples
person <- tibble::tibble(
id_hogar = c("h1", "h1", "h2"),
p01 = c(1, 2, 1),
p03 = c(40, 8, 45)
)
household <- tibble::tibble(
id_hogar = c("h1", "h2"),
vi03a = c(1, 2),
vi03b = c(1, 1),
vi04a = c(7, 1),
vi04b = c(1, 1),
vi05a = c(1, 6),
vi05b = c(1, 1),
vi07 = c(0, 1),
vi09 = c(5, 1),
vi10 = c(1, 2),
vi13 = c(2, 1)
)
joined <- enemdu_join_ipm_sources(person, household)
joined$vi03a
#> [1] 1 1 2