Age_at_instance: Age at instance

age_at_instanceR Documentation

Age at instance

Description

Age, in years, at the time of the specified instance.

age_at_instance uses the coded fields that contain the age (rounded to the nearest year) at each instance visit. age_at_instance_computed calculates a slightly more precise age based on the partipants year and month of birth.

Usage

age_at_instance(
  data,
  instance_num,
  age_at_instance_col = f.21003.0.0.Age_when_attended_assessment_centre
)

age_at_instance_computed(
  data,
  instance_num,
  date_of_instance_col = f.53.0.0.Date_of_attending_assessment_centre,
  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.).

instance_num

An integer specifying the instance number, or the name of the column (using <data-masking> rules) containing instance numbers to use in the current function.

age_at_instance_col

Template column name for age at instance.
Default = f.21003.0.0.Age_when_attended_assessment_centre.

date_of_instance_col

Template column name for date of each instance.
Default = f.53.0.0.Date_of_attending_assessment_centre.

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.

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.