This function creates a continuous derived variable (SMKG203_cont) for age started to smoke daily for daily smokers.
SMKG203_fun(SMK_005, SMKG040)
SMK_005 | type of smoker presently |
---|---|
SMKG040 | age started to smoke daily - daily/former daily smoker |
value for continuous age started to smoke daily for daily smokers in the SMKG203_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. Type of smoker presently is used to define daily smoker.
# Using SMKG203_fun() to derive age started to smoke daily values across # CCHS cycles. # SMKG203_fun() is specified in variable_details.csv along with the # CCHS variables and cycles included. # To transform SMKG203_A across cycles, use rec_with_table() for each # CCHS cycle and specify SMKG203_A. # For CCHS 2001-2014, only specify SMKG203_A. # For CCHS 2015-2018, specify the parameters and SMKG203_A for daily smoker # age. library(cchsflow) agecigd_2009_2010 <- rec_with_table( cchs2009_2010_p, "SMKG203_A")#>#>#>#> data frame with 0 columns and 6 rows#>#>#>#>#> SMK_005 SMKG040 #> 195 3 5 #> 196 3 NA(a) #> 197 3 NA(a) #> 198 3 NA(a) #> 199 3 5 #> 200 3 NA(a)combined_agecigd <- suppressWarnings(merge_rec_data (agecigd_2009_2010,agecigd_2017_2018)) head(combined_agecigd)#> SMK_005 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_005 SMKG040 #> 395 3 5 #> 396 3 NA(a) #> 397 3 NA(a) #> 398 3 NA(a) #> 399 3 5 #> 400 3 NA(a)