Sets value labels for one or more variables using one of three conventions.
Arguments
- x
A survey design object or a data frame.
- ...
Named arguments where the name is the variable and the value is a fully named vector of value labels. Supports
!!!list splicing.- variable
A character vector of variable names.
- labels
A list of named vectors, one per element of
variable. Whenvariablehas length 1, a bare named vector is also accepted.
Details
Convention 1 (named ...) — recommended:
set_val_labels(x, sex = c(Male = 1L, Female = 2L))Convention 2 (single named list in ...):
set_val_labels(x, list(sex = c(Male = 1L, Female = 2L)))Convention 3 (variable + labels):
set_val_labels(x, variable = "sex", labels = c(Male = 1L, Female = 2L))See also
extract_val_labels() to retrieve value labels
Other metadata:
extract_metadata(),
extract_missing_codes(),
extract_question_preface(),
extract_universe(),
extract_val_labels(),
extract_var_label(),
extract_var_note(),
infer_question_prefaces(),
set_missing_codes(),
set_question_preface(),
set_universe(),
set_var_label(),
set_var_note(),
survey_metadata(),
survey_weighting_history()
