# NOT RUN {
# Using bmi_fun() to create BMI values between cycles
# bmi_fun() is specified in variable_details.csv along with the
# CCHS variables and cycles included.
# To transform the derived BMI variable, use rec_with_table() for each cycle
# and specify HWTGBMI_der, along with height (HWTGHTM) and weight (HWTGWTK).
# Then by using merge_rec_data(), you can combined HWTGBMI_der across
# cycles.
library(cchsflow)
bmi2001 <- rec_with_table(
cchs2001_p, c(
"HWTGHTM",
"HWTGWTK", "HWTGBMI_der"
)
)
head(bmi2001)
bmi2011_2012 <- rec_with_table(
cchs2011_2012_p, c(
"HWTGHTM",
"HWTGWTK", "HWTGBMI_der"
)
)
tail(bmi2011_2012)
combined_bmi <- merge_rec_data(bmi2001, bmi2011_2012)
head(combined_bmi)
tail(combined_bmi)
# Using bmi_fun() to generate a BMI value with user inputted height and
# weight values. bmi_fun() can also generate a value for BMI if you input a
# value for height and weight. Let's say your height is 170cm (1.7m) and
# your weight is 50kg, your BMI can be calculated as follows:
library(cchsflow)
BMI <- bmi_fun(HWTGHTM = 1.7, HWTGWTK = 50)
print(BMI)
# }
Run the code above in your browser using DataLab