This is one of 2 functions used to create a derived variable (COPD_Emph_der) that determines if a respondents has either COPD or Emphysema. 2 different functions have been created to account for the fact that different respiratory variables are used across CCHS cycles. This function is for CCHS cycles (2001-2003, 2009-2014) that use COPD and Emphysema as a combined variable.
COPD_Emph_der_fun2(DHHGAGE_cont, CCC_091)
a categorical variable (COPD_Emph_der) with 3 levels:
respondent is over the age of 35 and has a respiratory condition
respondent is under the age of 35 and has a respiratory condition
respondent does not have a respiratory condition
COPD_Emph_der_fun2
# COPD_Emph_der_fun2() to create values across CCHS cycles
# (2001-2003, 2009-2014) COPD_Emph_der_fun2() is specified in
# variable_details.csv along with the CCHS variables and cycles included.
# To transform COPD_Emph_der, use rec_with_table() for each CCHS cycle
# and specify COPD_Emph_der, along with the various respiratory
# variables. Then by using merge_rec_data() you can combine COPD_Emph_der
# across cycles.
library(cchsflow)
COPD2001 <- suppressWarnings(rec_with_table(
cchs2001_p, c(
"DHHGAGE_cont", "CCC_091",
"COPD_Emph_der"
)
))
#> No variable_details detected.
#> Loading cchsflow variable_details
#> Using the passed data variable name as database_name
head(COPD2001)
#> CCC_091 DHHGAGE_cont COPD_Emph_der
#> 1 2 85 3
#> 2 2 85 3
#> 3 2 32 3
#> 4 2 77 3
#> 5 NA(a) 22 NA(a)
#> 6 2 77 3
COPD2014 <- suppressWarnings(rec_with_table(
cchs2007_2008_p, c(
"DHHGAGE_cont", "CCC_091",
"COPD_Emph_der"
)
))
#> No variable_details detected.
#> Loading cchsflow variable_details
#> Using the passed data variable name as database_name
tail(COPD2014)
#> DHHGAGE_cont
#> 195 62
#> 196 37
#> 197 77
#> 198 42
#> 199 32
#> 200 72
combined_COPD <- suppressWarnings(merge_rec_data(COPD2001, COPD2014))
head(combined_COPD)
#> CCC_091 DHHGAGE_cont COPD_Emph_der
#> 1 2 85 3
#> 2 2 85 3
#> 3 2 32 3
#> 4 2 77 3
#> 5 NA(a) 22 NA(a)
#> 6 2 77 3
tail(combined_COPD)
#> CCC_091 DHHGAGE_cont COPD_Emph_der
#> 395 NA(c) 62 NA(c)
#> 396 NA(c) 37 NA(c)
#> 397 NA(c) 77 NA(c)
#> 398 NA(c) 42 NA(c)
#> 399 NA(c) 32 NA(c)
#> 400 NA(c) 72 NA(c)