Description Usage Arguments Details Value Author(s) Examples
View source: R/derive_vars_aage.R
Derive Age in Years
1 | derive_var_age_years(dataset, age_var, age_unit = NULL, new_var)
|
dataset |
Input dataset. |
age_var |
AGE variable. |
age_unit |
AGE unit variable. The AGE unit variable is used to convert AGE to 'years' so that grouping can occur. This is only used when the age_var variable does not have a corresponding unit in the dataset. Default: NULL Permitted Values: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds' |
new_var |
New AGE variable to be created in years. |
This function is used to convert age variables into years. These can then be used to create age groups.
The input dataset with new_var paramater added in years.
Michael Thorpe
1 2 3 4 5 6 7 8 9 10 | library(dplyr, warn.conflicts = FALSE)
data <- data.frame(AGE = c(27, 24, 3, 4, 1),
AGEU = c("days", "months", "years", "weeks", "years"))
data %>%
derive_var_age_years(., AGE, new_var = AAGE)
data.frame(AGE = c(12, 24, 36, 48)) %>%
derive_var_age_years(., AGE, age_unit = "months", new_var = AAGE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.