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 (2005-2008) that use COPD and Emphysema as a combined variable.

COPD_Emph_der_fun1(DHHGAGE_cont, CCC_91E, CCC_91F)

Arguments

DHHGAGE_cont

continuous age variable.

CCC_91E

variable indicating if respondent has Emphysema

CCC_91F

variable indicating if respondent has COPD

Value

a categorical variable (COPD_Emph_der) with 3 levels:

  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 condition

  3. respondent does not have a respiratory condition

See also

Examples

# COPD_Emph_der_fun1() to create values across CCHS cycles
# (2005-2008) COPD_Emph_der_fun1() 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)

COPD2005 <- suppressWarnings(rec_with_table(
  cchs2005_p,  c(
    "DHHGAGE_cont", "CCC_91E", "CCC_91F",
    "COPD_Emph_der"
  )
))
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name

head(COPD2005)
#>   CCC_91E CCC_91F DHHGAGE_cont COPD_Emph_der
#> 1   NA(a)   NA(a)           27         NA(a)
#> 2       2       2           77             3
#> 3       2       2           32             3
#> 4       2       2           77             3
#> 5       2       2           85             3
#> 6   NA(a)   NA(a)           13         NA(a)

COPD2007_2008 <- suppressWarnings(rec_with_table(
  cchs2007_2008_p, c(
    "DHHGAGE_cont", "CCC_91E", "CCC_91F", 
    "COPD_Emph_der"
  )
))
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name

tail(COPD2007_2008)
#>     CCC_91E CCC_91F DHHGAGE_cont COPD_Emph_der
#> 195       2       2           62             3
#> 196       2       2           37             3
#> 197       2       2           77             3
#> 198       2       2           42             3
#> 199       2       2           32             3
#> 200       2       2           72             3

combined_COPD <- suppressWarnings(merge_rec_data(COPD2005, COPD2007_2008))

head(combined_COPD)
#>   CCC_91E CCC_91F DHHGAGE_cont COPD_Emph_der
#> 1   NA(a)   NA(a)           27         NA(a)
#> 2       2       2           77             3
#> 3       2       2           32             3
#> 4       2       2           77             3
#> 5       2       2           85             3
#> 6   NA(a)   NA(a)           13         NA(a)
tail(combined_COPD)
#>     CCC_91E CCC_91F DHHGAGE_cont COPD_Emph_der
#> 395       2       2           62             3
#> 396       2       2           37             3
#> 397       2       2           77             3
#> 398       2       2           42             3
#> 399       2       2           32             3
#> 400       2       2           72             3