derive_dob: Derive an estimated participant date of birth

View source: R/derived_variables.R

derive_dobR Documentation

Derive an estimated participant date of birth

Description

Estimates dates of birth from year and month of birth (Field IDs 34 and 52 respectively) as the first date of the month.

Usage

derive_dob(
  ukb_main,
  ukb_data_dict = get_ukb_data_dict(),
  .drop = FALSE,
  .details_only = FALSE
)

Arguments

ukb_main

A UK Biobank main dataset.

ukb_data_dict

The UKB data dictionary (available online at the UK Biobank data showcase. This should be a data frame where all columns are of type character.

.drop

If TRUE, remove the required input columns from the result

.details_only

If TRUE, return a list containing details of required input variables (Field IDs) and derived variables (new column name, label and values/value labels).

Value

A data frame with a column called dob (type character).

Examples

ukb_main <- data.frame(eid = 1, f34_0_0 = 1990, f52_0_0 = 1)
# dummy UKB data dictionary
dummy_ukb_data_dict <- get_ukb_dummy("dummy_Data_Dictionary_Showcase.tsv")

# keep input year/month of birth columns
derive_dob(ukb_main,
  ukb_data_dict = dummy_ukb_data_dict
)

# remove input year/month of birth columns
derive_dob(ukb_main,
  ukb_data_dict = dummy_ukb_data_dict,
  .drop = TRUE
)

rmgpanw/ukbwranglr documentation built on April 30, 2024, 7:47 a.m.