Skip to contents

For each column of x, this function checks whether value labels exist in value_labels. If so, integer values are replaced with these value labels.

Usage

data_label(
  x,
  variables = names(x),
  value_labels = read_yaml(paste0("value_labels_", substitute(x), ".yml"))
)

Arguments

x

A data.frame.

variables

Column names of x to replace, Default: names(x)

value_labels

A list with value labels, typically read from metadata generated by open_data or closed_data. Default: read_yaml(paste0("value_labels_", substitute(x), ".yml"))

Value

A data.frame.

Examples

if (FALSE) {
if(interactive()){
 labs <- list(x = list(class = "factor", `1` = "a", `2` = "b"))
 df <- data.frame(x = 1:2)
 data_label(df, value_labels = labs)
 }
}