Learn R Programming

sdcMicro (version 5.6.1)

selectHouseholdData: Creates a household level file from a dataset with a household structure.

Description

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.

Usage

selectHouseholdData(dat, hhId, hhVars)

Value

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

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

Author

Thijs Benschop and Bernhard Meindl

Examples

Run this code
## 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"))

Run the code above in your browser using DataLab