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).
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
)
#> eid f34_0_0 f52_0_0 dob
#> 1 1 1990 1 1990-01-01
# remove input year/month of birth columns
derive_dob(ukb_main,
ukb_data_dict = dummy_ukb_data_dict,
.drop = TRUE
)
#> eid dob
#> 1 1 1990-01-01