# NOT RUN {
# Using the 'smoke_simple_fun' function to create the derived smoking
# variable across CCHS cycles.
# smoke_simple_fun() is specified in the variable_details.csv
# To create a harmonized smoke_simple variable across CCHS cycles, use
# rec_with_table() for each CCHS cycle and specify smoke_simple_fun and
# the required base variables. Since time_quit_smoking_der is also a derived
# variable, you will have to specify the variables that are derived from it.
# Using merge_rec_data(), you can combine smoke_simple across cycles.
library(cchsflow)
smoke_simple2009_2010 <- rec_with_table(
cchs2009_2010_p, c(
"SMKDSTY", "SMK_09A_B", "SMKG09C", "time_quit_smoking",
"smoke_simple"
)
)
head(smoke_simple2009_2010)
smoke_simple2011_2012 <- rec_with_table(
cchs2011_2012_p,c(
"SMKDSTY", "SMK_09A_B", "SMKG09C", "time_quit_smoking",
"smoke_simple"
)
)
tail(smoke_simple2011_2012)
combined_smoke_simple <-
suppressWarnings(merge_rec_data(smoke_simple2009_2010,smoke_simple2011_2012))
head(combined_smoke_simple)
tail(combined_smoke_simple)
# }
Run the code above in your browser using DataLab