This function creates a categorical derived variable (pack_years_cat) that categorizes smoking pack-years (pack_years_der).

pack_years_fun_cat(pack_years_der)

Arguments

pack_years_der

derived variable that calculates smoking pack-years See pack_years_fun for documentation on how variable was derived.

Value

value for pack year categories in the pack_years_cat variable.

Details

pack-years is calculated by multiplying the number of cigarette packs per day (20 cigarettes per pack) by the number of years.The categories were based on the Cardiovascular Disease Population Risk Tool (Douglas Manuel et al. 2018).

pack_years_cat uses the derived variable pack_years_der. Pack_years_der uses age and various smoking variables that have been transformed by cchsflow (see documentation on pack_year_der). In order to categorize pack years across CCHS cycles, age and smoking variables must be transformed and harmonized.

Examples

 
# Using pack_years_fun_cat() to categorize pack year values across CCHS cycles
# pack_years_fun_cat() is specified in variable_details.csv along with the 
# CCHS variables and cycles included.

# To transform pack_years_cat across cycles, use rec_with_table() for each
# CCHS cycle and specify pack_years_cat.
# Since pack_year_der is also also derived variable, you will have to specify 
# the variables that are derived from it.
# Since time_quit_smoking_der is also a derived variable in pack_year_der, 
# you will have to specify the variables that are derived from it.
# Then by using merge_rec_data(), you can combine pack_years_cat across
# cycles.

library(cchsflow)

pack_years_cat_2009_2010 <- rec_with_table(
  cchs2009_2010_p, c(
    "SMKDSTY_A", "DHHGAGE_cont", "SMK_09A_B", "SMKG09C", "time_quit_smoking",
    "SMKG203_cont", "SMKG207_cont", "SMK_204", "SMK_05B", "SMK_208",
    "SMK_05C", "SMK_01A", "SMKG01C_cont", "pack_years_der", "pack_years_cat"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SMKG09C: Don't know (7) and refusal (8) not included in CCHS 2015-2016 and CCHS 2017-2018
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> Error in create_label_list_element(variable_rows) pack_years_cat does not contain all identical units variable cant change unit type for different values

head(pack_years_cat_2009_2010)
#> Error in head(pack_years_cat_2009_2010) object 'pack_years_cat_2009_2010' not found

pack_years_cat_2011_2012 <- rec_with_table(
  cchs2011_2012_p,c(
    "SMKDSTY_A", "DHHGAGE_cont", "SMK_09A_B", "SMKG09C", "time_quit_smoking",
    "SMKG203_cont", "SMKG207_cont", "SMK_204", "SMK_05B", "SMK_208",
    "SMK_05C", "SMK_01A", "SMKG01C_cont", "pack_years_der", "pack_years_cat"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SMKG09C: Don't know (7) and refusal (8) not included in CCHS 2015-2016 and CCHS 2017-2018
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> NOTE for SMKG207_cont: Missing 2001 Data
#> Error in create_label_list_element(variable_rows) pack_years_cat does not contain all identical units variable cant change unit type for different values

tail(pack_years_cat_2011_2012)
#> Error in tail(pack_years_cat_2011_2012) object 'pack_years_cat_2011_2012' not found

combined_pack_years_cat <- suppressWarnings(merge_rec_data
(pack_years_cat_2009_2010,pack_years_cat_2011_2012))
#> Error in list2(...) object 'pack_years_cat_2009_2010' not found

head(combined_pack_years_cat)
#> Error in head(combined_pack_years_cat) object 'combined_pack_years_cat' not found
tail(combined_pack_years_cat)
#> Error in tail(combined_pack_years_cat) object 'combined_pack_years_cat' not found