Return variable labels from a dataset

get_variable_labels(dataset, return_all = TRUE)



Can be either the file path to a dataset, the dataset as a `data.frame` or the filenames of datasets. See details for more information


Logical whether to return all variables (TRUE) or only those with labels.


A data.frame consisting of the variable name and labels.


Returns variable names and their labels from a dataset. You can pass for the `data` argument any of the following:

  • The file path to a saved dataset. This would be the direct output of get_datasets

  • A read in dataset, i.e. produced by using readRDS to load a dataset from a file path produced by get_datasets

  • Dataset filenames. These can be found as one of the returned fields from dhs_datasets. If these datasets have not been downloaded before this will download them for you.


if (FALSE) { # get the model datasets included with the package model_datasets <- model_datasets # download one of them g <- get_datasets(dataset_filenames = model_datasets$FileName[1]) # we can pass the list of filepaths to the function head(get_variable_labels(g)) # or we can pass the full dataset r <- readRDS(g[[1]]) head(get_variable_labels(r)) }