derive_var_age_years {admiral}R Documentation

Derive Age in Years

Description

Derive Age in Years

Usage

derive_var_age_years(dataset, age_var, age_unit = NULL, new_var)

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.

Value

The input dataset with new_var parameter added in years.

Author(s)

Michael Thorpe

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)

[Package admiral version 0.9.0 Index]