This function creates a continuous derived variable (SMKG207_cont) for age started to smoke daily for former daily smokers.
SMKG207_fun(SMK_030, SMKG040)
SMK_030 | smoked daily - lifetime (occasional/former smoker) |
---|---|
SMKG040 | age started to smoke daily - daily/former daily smoker |
value for continuous age started to smoke daily for former daily smokers in the SMKG207_cont variable
For CCHS 2015-2018, age started to smoke daily was combined for daily and former daily smokers.Previous cycles had separate variables for age started to smoke daily. Smoked daily in lifetime is used to define former daily smoker.
# Using SMKG207_fun() to derive age started to smoke daily values across # CCHS cycles. # SMKG207_fun() is specified in variable_details.csv along with the # CCHS variables and cycles included. # To transform SMKG207_A across cycles, use rec_with_table() for each # CCHS cycle and specify SMKG207_A. # For CCHS 2001-2014, only specify SMKG207_A. # For CCHS 2015-2018, specify the parameters and SMKG207_A for former daily # smoker age. library(cchsflow) agecigfd_2009_2010 <- rec_with_table( cchs2009_2010_p, "SMKG207_A")#>#>#>#> data frame with 0 columns and 6 rows#>#>#>#>#> SMK_030 SMKG040 #> 195 1 5 #> 196 NA(a) NA(a) #> 197 NA(a) NA(a) #> 198 NA(a) NA(a) #> 199 1 5 #> 200 NA(a) NA(a)combined_agecigfd <- suppressWarnings(merge_rec_data (agecigfd_2009_2010,agecigfd_2017_2018)) head(combined_agecigfd)#> SMK_030 SMKG040 #> 1 NA(c) NA(c) #> 2 NA(c) NA(c) #> 3 NA(c) NA(c) #> 4 NA(c) NA(c) #> 5 NA(c) NA(c) #> 6 NA(c) NA(c)#> SMK_030 SMKG040 #> 395 1 5 #> 396 NA(a) NA(a) #> 397 NA(a) NA(a) #> 398 NA(a) NA(a) #> 399 1 5 #> 400 NA(a) NA(a)