This function creates a derived variable (SMKDSTY_A) for smoker type with 5 categories:
daily smoker
current occasional smoker (former daily)
current occasional smoker (never daily)
current nonsmoker (former daily)
current nonsmoker (never daily)
nonsmoker
SMKDSTY_fun(SMK_005, SMK_030, SMK_01A)
SMK_005 | type of smoker presently |
---|---|
SMK_030 | smoked daily - lifetime (occasional/former smoker) |
SMK_01A | smoked 100 or more cigarettes in lifetime |
value for smoker type in the SMKDSTY_A variable
For CCHS 2001-2014, smoker type is derived from smoking more than 100 cigarettes in lifetime, type of smoker at present time, and ever smoked daily. For CCHS 2015-2018, smoker type was derived differently with different variables and categories. A function was created for a consistent smoker status across all cycles.
# Using SMKDSTY_fun() to derive smoke type values across CCHS cycles # SMKDSTY_fun() is specified in variable_details.csv along with the # CCHS variables and cycles included. # To transform SMKDSTY_A across cycles, use rec_with_table() for each # CCHS cycle and specify SMKDSTY_A. # For CCHS 2001-2014, only specify SMKDSTY_A for smoker type. # For CCHS 2015-2018, specify the parameters and SMKDSTY_A for smoker type. library(cchsflow) smoker_type_2009_2010 <- rec_with_table( cchs2009_2010_p, "SMKDSTY_A")#>#>#>#> SMKDSTY_A #> 1 6 #> 2 6 #> 3 5 #> 4 4 #> 5 4 #> 6 4smoker_type_2017_2018 <- rec_with_table( cchs2017_2018_p,c( "SMK_01A", "SMK_005","SMK_030","SMKDSTY_A" ) )#>#>#>#> SMK_005 SMK_030 SMK_01A SMKDSTY_A #> 195 3 1 1 4 #> 196 3 NA(a) 2 6 #> 197 3 NA(a) 2 6 #> 198 3 NA(a) 2 6 #> 199 3 1 1 4 #> 200 3 NA(a) 2 6combined_smoker_type <- suppressWarnings(merge_rec_data (smoker_type_2009_2010,smoker_type_2017_2018)) head(combined_smoker_type)#> SMKDSTY_A SMK_005 SMK_030 SMK_01A #> 1 6 NA(c) NA(c) NA(c) #> 2 6 NA(c) NA(c) NA(c) #> 3 5 NA(c) NA(c) NA(c) #> 4 4 NA(c) NA(c) NA(c) #> 5 4 NA(c) NA(c) NA(c) #> 6 4 NA(c) NA(c) NA(c)#> SMKDSTY_A SMK_005 SMK_030 SMK_01A #> 395 4 3 1 1 #> 396 6 3 NA(a) 2 #> 397 6 3 NA(a) 2 #> 398 6 3 NA(a) 2 #> 399 4 3 1 1 #> 400 6 3 NA(a) 2