smoke_simple_fun {cchsflow}R Documentation

Simple smoking status

Description

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

Usage

smoke_simple_fun(SMKDSTY_cat5, time_quit_smoking)

Arguments

SMKDSTY_cat5

derived variable that classifies an individual's smoking status. This variable captures cycles 2001-2018.

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

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

[Package cchsflow version 2.1.0 Index]