View source: R/derive_vars_aage.R
derive_var_age_years | R Documentation |
Converts the given age variable (age_var
) to the unit 'years' from the current
units given in the age_var+U
variable or age_unit
argument and stores
in a new variable (new_var
).
derive_var_age_years(dataset, age_var, age_unit = NULL, new_var)
dataset |
Input dataset The variables specified by the |
age_var |
Age variable. A numeric object is expected. |
age_unit |
Age unit. The Default: NULL Permitted Values: 'years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds' |
new_var |
New age variable to be created in years. The returned values are doubles and NOT integers. ' |
This function is used to convert an age variable into the unit 'years' which can then be used to create age groups. The resulting column contains the equivalent years as a double. Note, underlying computations assume an equal number of days in each year (365.25).
The input dataset (dataset
) with new_var
variable added in years.
derive_vars_duration()
ADSL Functions that returns variable appended to dataset:
derive_vars_aage()
,
derive_vars_extreme_event()
,
derive_vars_period()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.