smoke_simple_fun: Simple smoking status

Description Usage Arguments Examples

View source: R/smoking.R

Description

This function creates a derived smoking variable (smoke_simple) with four categories:

Usage

1
smoke_simple_fun(SMKDSTY, time_quit_smoking)

Arguments

SMKDSTY

derived variable that classifies an individual's smoking status.

time_quit_smoking

derived variable that calculates the approximate time a former smoker has quit smoking. See time_quit_smoking_fun for documentation on how variable was derived.

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
34
35
# 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)

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