Skip to contents

If no replacement exists, keeps the original.

Usage

replace_stata_labels(
  data,
  df_new_labels,
  var_name_col = "name",
  var_label_col = "vallab_full",
  trim = c("both", "all"),
  overwrite = TRUE
)

Arguments

data

data frame for which labels will be replaced

df_new_labels

a data frame with a var_name_col and a var_label_col

var_name_col, var_label_col

variable names (as strings) for the lookup of variable names in data, and the corresponding variable label.

trim

string, trim "both" sides (default), "left" or "right".

overwrite

Flag. Whether to remove label if it already exists.

Value

data, with variable labels replaced