Derive Age in Years
Arguments
- 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.
Details
This function is used to convert age variables into years. These can then be used to create age groups.
See also
ADSL Functions that returns variable appended to dataset:
derive_var_disposition_status()
,
derive_var_dthcaus()
,
derive_var_extreme_dtm()
,
derive_var_extreme_dt()
,
derive_vars_aage()
,
derive_vars_disposition_reason()
,
derive_vars_period()
Examples
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)