# NOT RUN {
# Using adjusted_bmi_fun() to create adjusted BMI values between cycles
# adjusted_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 HWTGCOR_der, along with sex (DHH_SEX), height (HWTGHTM) and
# weight (HWTGWTK).Then by using merge_rec_data(), you can combined
# HWTGBMI_der across cycles.
library(cchsflow)
adjustedbmi2001 <- rec_with_table(
cchs2001_p, c(
"HWTGHTM",
"HWTGWTK",
"DHH_SEX",
"HWTGCOR_der"
)
)
head(adjustedbmi2001)
adjustedbmi2011_2012 <- rec_with_table(
cchs2011_2012_p, c(
"HWTGHTM",
"HWTGWTK",
"DHH_SEX",
"HWTGCOR_der"
)
)
tail(adjustedbmi2011_2012)
combined_bmi <- merge_rec_data(adjustedbmi2001, adjustedbmi2011_2012)
head(combined_bmi)
tail(combined_bmi)
# adjusted_bmi_fun() can also generate a value for BMI if you input your sex,
# and a value for height and weight. Let's say your sex is male, height is
# 170cm (1.7m) and your weight is 50kg, your BMI can be calculated as follows:
library(cchsflow)
adjusted_BMI <- adjusted_bmi_fun(DHH_SEX = 1, HWTGHTM = 1.7, HWTGWTK = 50)
print(adjusted_BMI)
# }
Run the code above in your browser using DataLab