Age_at_date: Age at date

age_at_dateR Documentation

Age at date

Description

Get age (in years) as of a particular date.

NOTE: This result is approximate, since only the year and month of birth are provided. The day of birth is assumed to be 15.

Usage

age_at_date(
  data,
  date,
  year_of_birth_col = f.34.0.0.Year_of_birth,
  month_of_birth_col = f.52.0.0.Month_of_birth
)

Arguments

data

The primarydata frame.

Thisdata frame includes all necessary columns required to perform look-ups (e.g. ICD10 code columns, medication code columns, age, sex, etc.).

date

Target date, as a string which is then passed to lubridate::as_date().

year_of_birth_col

Template column name for year of birth.
Default = f.34.0.0.Year_of_birth.

month_of_birth_col

Template column name for month of birth.
Default = f.52.0.0.Month_of_birth.

Value

Numeric vector of age in years (age_at_date()), or character vector of age groups (age_group_at_date())

Column names

Most functions in this package will take column names (*_col) as optional arguments (otherwise a default column names are used) which are then used as templates to find all other columns with the same field number, but different instance and array numbers. These functions will automatically find all matching instances (and arrays within each instance) within the specified parameters. Internally, a set of expand_instance_*() helper functions, which themselves rely on the column_expansion_helper() function, perform the work of searching for matching columns.


adamleejohnson/R-ukbiobank documentation built on April 25, 2022, 2:11 a.m.