This function creates a derived variable for daily time spent traveling in active ways. This includes walking and biking. This function is used for CCHS 2015-2018.
active_transport3_fun(PAYDVTTR, PAADVTRV)
Continuous variable for active transportation (active_transport)
# Using active_transport3_fun() to determine daily time spent
# traveling in active ways values across CCHS 2015-2018.
# active_transport3_fun() is specified in variable_details.csv along with the CCHS
# variables and cycles included.
# To transform active_transport across cycles, use rec_with_table() for each
# CCHS cycle and specify active_transport, along with each activity variable.
# Then by using merge_rec_data(), you can combine active_transport across
# cycles
library(cchsflow)
active_transport2015_2016 <- rec_with_table(
cchs2015_2016_p, c(
"PAYDVTTR", "PAADVTRV","active_transport"
)
)
#> No variable_details detected.
#> Loading cchsflow variable_details
#> Using the passed data variable name as database_name
head(active_transport2015_2016)
#> PAADVTRV PAYDVTTR active_transport
#> 1 0 NA 0
#> 2 0 NA 0
#> 3 NA NA NA
#> 4 0 NA 0
#> 5 0 NA 0
#> 6 0 NA 0
active_transport2017_2018 <- rec_with_table(
cchs2017_2018_p, c(
"PAYDVTTR", "PAADVTRV","active_transport"
)
)
#> No variable_details detected.
#> Loading cchsflow variable_details
#> Using the passed data variable name as database_name
tail(active_transport2017_2018)
#> PAADVTRV PAYDVTTR active_transport
#> 195 0 NA 0.00000
#> 196 600 NA 85.71429
#> 197 NA 1620 231.42857
#> 198 9000 NA 1285.71429
#> 199 90 NA 12.85714
#> 200 0 NA 0.00000
combined_active_transport <- suppressWarnings(merge_rec_data(
active_transport2015_2016, active_transport2017_2018))
head(combined_active_transport)
#> PAADVTRV PAYDVTTR active_transport
#> 1 0 NA 0
#> 2 0 NA 0
#> 3 NA NA NA
#> 4 0 NA 0
#> 5 0 NA 0
#> 6 0 NA 0
tail(combined_active_transport)
#> PAADVTRV PAYDVTTR active_transport
#> 395 0 NA 0.00000
#> 396 600 NA 85.71429
#> 397 NA 1620 231.42857
#> 398 9000 NA 1285.71429
#> 399 90 NA 12.85714
#> 400 0 NA 0.00000