time_quit_smoking_fun: Time since quit smoking

Description Usage Arguments Value Examples

View source: R/smoking.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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)

cchsflow documentation built on June 24, 2021, 1:07 a.m.