Stores variable labels, value labels, question prefaces, notes, and
transformation history for variables in a survey design object.
Automatically populated from haven-style attributes when
as_survey() or related constructors are called.
Arguments
- variable_labels
A named list mapping variable names to character labels (e.g.,
list(age = "Age in years")).- value_labels
A named list mapping variable names to named vectors of value labels (e.g.,
list(sex = c(Male = 1L, Female = 2L))).- question_prefaces
A named list mapping variable names to shared question battery preface text.
- notes
A named list mapping variable names to analyst notes.
- universe
A named list mapping variable names to universe descriptions (e.g.,
list(age = "Adults 18+")). Describes the population to which a variable applies.- missing_codes
A named list mapping variable names to atomic vectors of missing-value codes (e.g.,
list(age = c(Refused = 99L, DK = 98L))).- transformations
A named list tracking variable transformation history (populated automatically during operations).
- weighting_history
A list recording weighting operations applied to the survey object (e.g., raking, trimming). Each entry is written by a surveywts function and contains the operation name, parameters, effective sample size before/after, and design effect. Always
list()until a surveywts weighting function is applied. Reserved for Phase 2.5.
See also
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_label(),
set_var_note(),
survey_weighting_history()
Examples
# Empty metadata (default)
m <- survey_metadata()
m@variable_labels
#> list()
# Pre-populated metadata
m <- survey_metadata(
variable_labels = list(age = "Respondent age", income = "Annual income"),
value_labels = list(sex = c(Male = 1L, Female = 2L))
)
m@variable_labels$age
#> [1] "Respondent age"
m@value_labels$sex
#> Male Female
#> 1 2
