Sets variable labels using one of three conventions.
Details
Convention 1 (named ...) — recommended for interactive use:
set_var_label(x, age = "Age in years", income = "Annual income")
set_var_label(x, !!!labels_list) # list splicingConvention 2 (named vector in ...) — useful for programmatic use:
set_var_label(x, c(age = "Age in years", income = "Annual income"))Convention 3 (variable + label arguments) — for vector input:
vars <- c("age", "income")
lbls <- c("Age in years", "Annual income")
set_var_label(x, variable = vars, label = lbls)See also
extract_var_label() to retrieve a label
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_val_labels(),
set_var_note(),
survey_metadata(),
survey_weighting_history()
Examples
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
strata = sdmvstra, nest = TRUE)
d <- set_var_label(d, indfmpir = "Income-to-poverty ratio")
# Multiple variables
d <- set_var_label(d, bpxsy1 = "Systolic BP (1st reading)",
bpxdi1 = "Diastolic BP (1st reading)")
