# NOT RUN {
# Using pack_years_fun() to create pack-years values across CCHS cycles
# pack_years_fun() is specified in variable_details.csv along with the CCHS
# variables and cycles included.
# To transform pack_years_der across cycles, use rec_with_table() for each
# CCHS cycle and specify pack_years_der, along with each smoking variable.
# Since time_quit_smoking_der is also a derived
# variable, you will have to specify the variables that are derived from it.
# Then by using merge_rec_data(), you can combine pack_years_der across
# cycles
library(cchsflow)
pack_years2009_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"
)
)
head(pack_years2009_2010)
pack_years2011_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"
)
)
tail(pack_years2011_2012)
combined_pack_years <- suppressWarnings(merge_rec_data(pack_years2009_2010,
pack_years2011_2012))
head(combined_pack_years)
tail(combined_pack_years)
# }
Run the code above in your browser using DataLab