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)
pack_years_der | derived variable that calculates smoking pack-years
See |
---|
value for pack year categories in the pack_years_cat variable.
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.
# 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" ) )#>#>#>#>#>#>#>#>#>#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 1 13 2 NA NA NA(a) NA NA 6 #> 2 27 2 NA NA NA(a) NA NA 6 #> 3 62 2 NA NA NA(a) NA NA 5 #> 4 52 1 NA NA 4 NA 20 4 #> 5 67 1 NA NA 4 NA 35 4 #> 6 62 1 NA NA 4 NA 25 4 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 1 NA NA(a) NA NA NA #> 2 NA NA(a) NA NA NA #> 3 16 NA(a) NA NA NA #> 4 16 2 NA 18.5 8 #> 5 16 3 NA 16.0 12 #> 6 8 3 NA 8.0 12 #> pack_years_der pack_years_cat #> 1 0.000 1 #> 2 0.000 1 #> 3 0.007 2 #> 4 25.500 6 #> 5 68.250 8 #> 6 52.500 8pack_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" ) )#>#>#>#>#>#>#>#>#>#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 195 72.0 1 NA NA 4 NA 3 4 #> 196 22.0 2 NA NA NA(a) NA NA 5 #> 197 18.5 2 NA NA NA(a) NA NA 6 #> 198 42.0 1 NA NA 4 NA 10 4 #> 199 62.0 1 NA NA NA(a) 20 NA 1 #> 200 52.0 1 NA NA NA(a) 13 NA 1 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 195 16 3 NA 16 12 #> 196 13 NA(a) NA NA NA #> 197 NA NA(a) NA NA NA #> 198 16 2 NA 16 8 #> 199 16 NA(a) NA NA NA #> 200 13 NA(a) 16 NA NA #> pack_years_der pack_years_cat #> 195 6.600 4 #> 196 0.007 2 #> 197 0.000 1 #> 198 9.000 4 #> 199 NA NA(b) #> 200 23.400 6combined_pack_years_cat <- suppressWarnings(merge_rec_data (pack_years_cat_2009_2010,pack_years_cat_2011_2012)) head(combined_pack_years_cat)#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 1 13 2 NA NA NA(a) NA NA 6 #> 2 27 2 NA NA NA(a) NA NA 6 #> 3 62 2 NA NA NA(a) NA NA 5 #> 4 52 1 NA NA 4 NA 20 4 #> 5 67 1 NA NA 4 NA 35 4 #> 6 62 1 NA NA 4 NA 25 4 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 1 NA NA(a) NA NA NA #> 2 NA NA(a) NA NA NA #> 3 16 NA(a) NA NA NA #> 4 16 2 NA 18.5 8 #> 5 16 3 NA 16.0 12 #> 6 8 3 NA 8.0 12 #> pack_years_der pack_years_cat #> 1 0.000 1 #> 2 0.000 1 #> 3 0.007 2 #> 4 25.500 6 #> 5 68.250 8 #> 6 52.500 8#> DHHGAGE_cont SMK_01A SMK_05B SMK_05C SMK_09A_B SMK_204 SMK_208 SMKDSTY_A #> 395 72.0 1 NA NA 4 NA 3 4 #> 396 22.0 2 NA NA NA(a) NA NA 5 #> 397 18.5 2 NA NA NA(a) NA NA 6 #> 398 42.0 1 NA NA 4 NA 10 4 #> 399 62.0 1 NA NA NA(a) 20 NA 1 #> 400 52.0 1 NA NA NA(a) 13 NA 1 #> SMKG01C_cont SMKG09C SMKG203_cont SMKG207_cont time_quit_smoking #> 395 16 3 NA 16 12 #> 396 13 NA(a) NA NA NA #> 397 NA NA(a) NA NA NA #> 398 16 2 NA 16 8 #> 399 16 NA(a) NA NA NA #> 400 13 NA(a) 16 NA NA #> pack_years_der pack_years_cat #> 395 6.600 4 #> 396 0.007 2 #> 397 0.000 1 #> 398 9.000 4 #> 399 NA NA(b) #> 400 23.400 6