R/GUIfunctions.R
selectHouseholdData.Rd
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)
a data.frame with the full dataset
name of the variable with the household (cluster) ID
character vector with names of all household level variables
a data.frame with only household level variables and one record per household
It is of great importance that users select a variable with containing information on household-ids and weights in hhVars
.
## 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"))