Skip to contents

add_loop_age_dummy() adds a dummy variable for an age class in the demographics loop. add_loop_age_dummy_to_main() adds the sum of the age dummy variable to the main dataset. add_loop_age_gender_dummy() and add_loop_age_gender_dummy_to_main() do the same with the gender dimension included.

Usage

add_loop_age_dummy(
  loop,
  ind_age = "ind_age",
  lb = 5,
  ub = 18,
  new_colname = NULL
)

add_loop_age_dummy_to_main(
  main,
  loop,
  ind_age_dummy = "ind_age_5_18",
  id_col_main = "uuid",
  id_col_loop = "uuid",
  new_colname = NULL
)

add_loop_age_gender_dummy(
  loop,
  ind_age = "ind_age",
  lb = 5,
  ub = 18,
  ind_gender = "ind_gender",
  gender = "female",
  new_colname = NULL
)

add_loop_age_gender_dummy_to_main(
  main,
  loop,
  ind_age_gender_dummy = "ind_age_female_5_18",
  id_col_main = "uuid",
  id_col_loop = "uuid",
  new_colname = NULL
)

Arguments

loop

A data frame of individual-level data.

ind_age

Column name for individual age.

lb

Lower bound for the age class.

ub

Upper bound for the age class.

new_colname

New column name for the dummy variable. If NULL, then the default is "ind_age_lb_ub" or "ind_dummy_n" or "ind_age_gender_lb_ub" or "ind_age_gender_dummy_n" depending on the function used.

main

A data frame of household-level data.

ind_age_dummy

Column name for the dummy variable of the age class.

id_col_main

Column name for the unique identifier in the main dataset.

id_col_loop

Column name for the unique identifier in the loop dataset.

ind_gender

Column name for individual gender.

gender

Response options of interest, e.g. "Female".

ind_age_gender_dummy

Column name for the dummy variable of the age-gender class.