label_ukb_main | R Documentation |
Applies variable labels and factor labels to coded values in a UK Biobank main dataset.
label_ukb_main(
ukb_main,
data_dict,
ukb_codings = get_ukb_codings(),
colnames_col = "descriptive_colnames",
max_n_labels = 30
)
ukb_main |
A UK Biobank main dataset (data frame) |
data_dict |
A data dictionary specific to the UKB main dataset file,
generated by |
ukb_codings |
The UKB codings file (available online at the UK Biobank
data
showcase. This should be a data frame where all columns are of type
|
colnames_col |
The name of the column in |
max_n_labels |
Coded variables with associated value labels less than or
equal to this threshold will be labelled as factors. If |
A data frame.
## Not run:
# get dummy UKB data dictionary and codings
dummy_ukb_data_dict <- get_ukb_dummy("dummy_Data_Dictionary_Showcase.tsv")
dummy_ukb_codings <- get_ukb_dummy("dummy_Codings.tsv")
# file path to dummy UKB main dataset
dummy_ukb_main_path <- get_ukb_dummy("dummy_ukb_main.tsv", path_only = TRUE)
# to read only a subset of variables, create a data dictionary and filter
# for selected variables, then supply to `read_ukb()`
data_dict_selected <- make_data_dict(
ukb_main = dummy_ukb_main_path,
ukb_data_dict = dummy_ukb_data_dict
) %>%
dplyr::filter(FieldID %in% c("eid", "31", "34", "21001"))
# read ukb_main as is, and label afterwards
read_ukb(
path = dummy_ukb_main_path,
data_dict = data_dict_selected,
ukb_data_dict = dummy_ukb_data_dict,
ukb_codings = dummy_ukb_codings,
descriptive_colnames = TRUE,
label = FALSE
) %>%
label_ukb_main(
data_dict = data_dict_selected,
ukb_codings = dummy_ukb_codings,
colnames_col = "descriptive_colnames"
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.