time_quit_smoking_fun {cchsflow} | R Documentation |
Time since quit smoking
Description
This function creates a derived variable (time_quit_smoking_der) that calculates the approximate time a former smoker has quit smoking based on various CCHS smoking variables. This variable is for CCHS respondents in CCHS surveys 2003-2014.
Usage
time_quit_smoking_fun(SMK_09A_B, SMKG09C)
Arguments
SMK_09A_B |
number of years since quitting smoking. Variable asked to former daily smokers who quit <3 years ago. |
SMKG09C |
number of years since quitting smoking. Variable asked to former daily smokers who quit >=3 years ago. |
Value
value for time since quit smoking in time_quit_smoking_der.
Examples
# Using time_quit_smoking_fun() to create pack-years values across CCHS
# cycles.
# time_quit_smoking_fun() is specified in variable_details.csv along with the
# CCHS variables and cycles included.
# To transform time_quit_smoking across cycles, use rec_with_table() for each
# CCHS cycle and specify time_quit_smoking, along with each smoking variable.
# Then by using merge_rec_data(), you can combine time_quit_smoking across
# cycles.
library(cchsflow)
time_quit2009_2010 <- rec_with_table(
cchs2009_2010_p, c(
"SMK_09A_B", "SMKG09C", "time_quit_smoking"
)
)
head(time_quit2009_2010)
time_quit2011_2012 <- rec_with_table(
cchs2011_2012_p, c(
"SMK_09A_B", "SMKG09C", "time_quit_smoking"
)
)
tail(time_quit2011_2012)
combined_time_quit <- suppressWarnings(merge_rec_data(time_quit2009_2010,
time_quit2011_2012))
head(combined_time_quit)
tail(combined_time_quit)
[Package cchsflow version 2.1.0 Index]