This function creates a categorical derived variable (pct_time_der_cat10) that categorizes the derived percent time in Canada variable (pct_time_der).

pct_time_fun_cat(pct_time_der)

Arguments

pct_time_der

derived continuous percent time in Canada. See pct_time_fun for documentation on how variable was derived.

Value

value for categorical percent time in Canada using pct_time_der variable.

Details

The percent time in Canada provides an estimated percentage of the time a person's life was spent in Canada.The categorical percent time in Canada divides the continuous value into 10 percent intervals.

pct_time_der_cat10 uses the derived variable pct_time_der. pct_time_der uses various variables that have been transformed by cchsflow (see documentation on pct_time_der). In order to categorize percent time in Canada across CCHS cycles, the variables must be transformed and harmonized.

Examples

# Using pct_time_fun_cat() to create categorical percent time values 
# between CCHS cycles.
# pct_time_fun_cat() is specified in variable_details.csv along with the CCHS
# variables and cycles included.

# To transform pct_time_der_cat10 across cycles, use rec_with_table() for 
# each CCHS cycle.
# Since pct_time_der is a derived variable, you will have to specify the 
# variables that are derived from it.
# Then by using merge_rec_data(), you can combine pct_time_der_cat10 across 
# cycles.

library(cchsflow)
pct_time_cat2009_2010 <- rec_with_table(
  cchs2009_2010_p, c(
    "DHHGAGE_cont", "SDCGCBG",
    "SDCGRES", "pct_time_der", "pct_time_der_cat10"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SDCGCBG: CCHS 2001 does not have don't know (7) or refusal (8)
#> NOTE for SDCGRES: CCHS 2001 missing don't know (7), refusal (8)
#> Error in create_label_list_element(variable_rows) pct_time_der_cat10 does not contain all identical units variable cant change unit type for different values
head(pct_time_cat2009_2010)
#> Error in head(pct_time_cat2009_2010) object 'pct_time_cat2009_2010' not found

pct_time_cat2011_2012 <- rec_with_table(
  cchs2011_2012_p,  c(
    "DHHGAGE_cont", "SDCGCBG",
    "SDCGRES", "pct_time_der", "pct_time_der_cat10"
  )
)
#> No variable_details detected.
#>               Loading cchsflow variable_details
#> Using the passed data variable name as database_name
#> NOTE for SDCGCBG: CCHS 2001 does not have don't know (7) or refusal (8)
#> NOTE for SDCGRES: CCHS 2001 missing don't know (7), refusal (8)
#> Error in create_label_list_element(variable_rows) pct_time_der_cat10 does not contain all identical units variable cant change unit type for different values
tail(pct_time_cat2011_2012)
#> Error in tail(pct_time_cat2011_2012) object 'pct_time_cat2011_2012' not found

combined_pct_time_cat <- merge_rec_data(pct_time_cat2009_2010, 
pct_time_cat2011_2012)
#> Error in list2(...) object 'pct_time_cat2009_2010' not found
head(combined_pct_time_cat)
#> Error in head(combined_pct_time_cat) object 'combined_pct_time_cat' not found
tail(combined_pct_time_cat)
#> Error in tail(combined_pct_time_cat) object 'combined_pct_time_cat' not found