library(tibble)
# Derive age with age units specified
data <- tribble(
~AGE, ~AGEU,
27, "days",
24, "months",
3, "years",
4, "weeks",
1, "years"
)
derive_var_age_years(data, AGE, new_var = AAGE)
# Derive age without age units variable specified
data <- tribble(
~AGE,
12,
24,
36,
48
)
derive_var_age_years(data, AGE, age_unit = "months", new_var = AAGE)
Run the code above in your browser using DataLab