It removes individual level variables and selects one record per household based on a household ID. The function can also be used for other hierachical structures.

selectHouseholdData(dat, hhId, hhVars)

Arguments

dat

a data.frame with the full dataset

hhId

name of the variable with the household (cluster) ID

hhVars

character vector with names of all household level variables

Value

a data.frame with only household level variables and one record per household

Note

It is of great importance that users select a variable with containing information on household-ids and weights in hhVars.

Author

Thijs Benschop and Bernhard Meindl

Examples

## ori-hid: household-ids; household_weights: sampling weights for households
x_hh <- selectHouseholdData(dat=testdata, hhId="ori_hid",
  hhVars=c("urbrur", "roof",  "walls", "water", "electcon", "household_weights"))