R/number-conditions.R
multiple_conditions_fun2.Rd
This function generates a derived variable (number_conditions) that counts the number of chronic conditions a respondent has. This function takes 6 CCHS-defined conditions (heart disease, cancer, stroke, bowel disorder, mood disorder and arthritis), and well one derived variable (respiratory condition) to count the number of conditions a respondent has.
multiple_conditions_fun2(
CCC_121,
CCC_131,
CCC_151,
CCC_171,
CCC_280,
resp_condition_der,
CCC_051
)
variable indicating if respondent has heart disease (1 = respondent has heart disease, 2 = respondent does not have heart disease)
variable indicating if respondent has active cancer (1 = respondent has active cancer, 2 = respondent does not have active cancer)
variable indicating if respondent suffers from the effects of a stroke (1 = respondent suffers from stroke effects, 2 = respondent does not suffer from stroke effects)
variable indicating if respondent has a bowel disorder (1 = respondent has bowel disorder, 2 = respondent does not have a bowel disorder)
variable indicating if respondent has a mood disorder (1 = respondent has a mood disorder, 2 = respondent does not have a mood disorder. Note, variable was not asked to respondents in the 2001 CCHS survey cycle.
derived variable indicating if respondent has a
respiratory condition. (1 = respondent is over the age of 35 and has
a respiratory condition, 2 = respondent is under the age of 35 and has a
respiratory conditions, 3 = respondent does not have a respiratory
condition). See resp_condition_fun1
for
documentation on how variable was derived.
variable indicating if respondent has arthritis or rheumatism (1 = respondent has arthritis or rheumatism, 2 = respondent does not have arthritis or rheumatism)
A categorical variable indicating the number of chronic conditions a respondent has. Respondents with 5 or more conditions are grouped in the "5+" category.
mood disorder (CCC_280) was not asked to respondents in the 2001
CCHS survey cycle. This mean respondents in this cycle will only be able to
have a maximum of 6 chronic conditions as opposed to 7 for respondents in
other cycles. multiple_conditions_fun1
is used for CCHS cycles
from 2003 to 2014.
# 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")))
#> No variable_details detected.
#> Loading cchsflow variable_details
#> Using the passed data variable name as database_name
head(conditions_2009_2010)
#> CCC_031 CCC_051 CCC_091 CCC_121 CCC_131 CCC_151 CCC_171 CCC_280 DHHGAGE_cont
#> 1 2 NA(a) NA(a) 2 2 2 2 2 13
#> 2 2 2 NA(a) 2 2 2 2 2 27
#> 3 2 1 2 2 2 2 2 1 62
#> 4 2 2 2 2 2 2 2 2 52
#> 5 2 2 2 2 2 2 2 2 67
#> 6 2 1 2 2 2 2 2 2 62
#> resp_condition_der number_conditions
#> 1 3 1
#> 2 3 1
#> 3 3 3
#> 4 3 1
#> 5 3 1
#> 6 3 2
# 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)
#> [1] 3