make_data_dict: Generate a UK Biobank data dictionary

View source: R/read_ukb.R

make_data_dictR Documentation

Generate a UK Biobank data dictionary

Description

Creates a data dictionary for a raw UK Biobank main dataset, either using file path or from a data frame if the dataset has already been loaded into R.

Usage

make_data_dict(ukb_main, delim = "auto", ukb_data_dict = get_ukb_data_dict())

Arguments

ukb_main

Either the path to a UK Biobank main dataset file (character string) or a data frame.

delim

Delimiter for the UKB main dataset file. Default is "auto" (see data.table::fread()). Ignored if the file name ends with .dta (i.e. is a STATA file) or if ukb_main is a data frame.

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.

Value

A data dictionary (data frame) specific to ukb_main. This includes columns with descriptive column names ("descriptive_colnames") and the current column names ("colheaders_raw").

Examples

# dummy UKB data dictionary
dummy_ukb_data_dict <- get_ukb_dummy("dummy_Data_Dictionary_Showcase.tsv")

# create data dictionary specific to UKB main dataset, either using file path
make_data_dict(
  ukb_main = get_ukb_dummy("dummy_ukb_main.tsv", path_only = TRUE),
  ukb_data_dict = dummy_ukb_data_dict
)

# ...or from data frame
make_data_dict(
  ukb_main = get_ukb_dummy("dummy_ukb_main.tsv"),
  ukb_data_dict = dummy_ukb_data_dict
)

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