# NOT RUN {
# Using rec_with_table() to generate multiple_conditions in a CCHS
# cycle.
# multiple_conditions_fun2() is specified in variable_details.csv along with
# the CCHS variables and cycles included.
# To generate multiple_conditions, use rec_with_table() and specify the
# multiple_conditions, along with the variables that are derived from it.
# Since resp_condition_der is also a derived variable, you will have to
# specify the variables that are derived from it. In this example, data
# from the 2010 CCHS will be used, so DHHGAGE_cont, CCC_091, and CCC_031
# will be specified along with resp_condition_der.
library(cchsflow)
conditions_2009_2010 <- suppressWarnings(rec_with_table(cchs2009_2010_p,
c("DHHGAGE_cont", "CCC_091",
"CCC_031", "CCC_121","CCC_131","CCC_151", "CCC_171","CCC_280",
"resp_condition_der","CCC_051", "number_conditions")))
head(conditions_2009_2010)
# Generating multiple_conditions with user inputted values
# Let's say you are an individual that has heart disease, bowel disorder,
# and arthritis. multiple_conditions_fun2() can be used to count the number
# of chronic conditions you have
library(cchsflow)
num_conditions <- multiple_conditions_fun2(CCC_121 = 1, CCC_131 = 2,
CCC_151 = 2, CCC_171 = 1, CCC_280 = 2, resp_condition_der = 3, CCC_051 = 1)
print(num_conditions)
# }
Run the code above in your browser using DataLab