Returns the extension-slot payload for one or more variables in a survey design object or data frame. Read-only; performs no validation of payload contents — values are returned exactly as stored, never coerced.
Arguments
- x
A survey design object or
data.frame.- ...
<
tidy-select> Variables to query. Supports selection helpers:tidyselect::starts_with(),tidyselect::all_of(),tidyselect::any_of(),tidyselect::matches(), etc. If empty, returns the payload for every column inx. Usetidyselect::any_of()to silently skip missing variable names.- format
character(1). Output format:"list"(default) or"data_frame"."named_vector"is not valid for this function (payloads are not scalar).- fill
Scalar or
NULL. How to handle variables with no payload:NULL(default) omits them;NA_character_includes them asNULLentries in"list"format. In"data_frame"format, variables with no payload are always excluded regardless offill.
Value
"list"(default): named list. Keys are variable names; values are each variable's stored payload, orNULLfor variables included viafill = NA_character_with no payload set. Empty:list()."data_frame": a tibble with columnsvariable(character),key(character), andvalue(a list-column, one raw payload value per row, unvalidated and untouched). One row per(variable, key)pair; a variable whose payload islist()or unset contributes zero rows. Empty: a zero-row tibble typed as above.
See also
set_var_extra() to set an extension-slot payload
Other metadata:
classify_question_type(),
extract_data_name(),
extract_dataset_metadata(),
extract_field_dates(),
extract_field_period(),
extract_higher_is(),
extract_metadata(),
extract_missing_codes(),
extract_question_preface(),
extract_reverse_coded(),
extract_sata(),
extract_survey_name(),
extract_universe(),
extract_val_labels(),
extract_var_label(),
extract_var_note(),
extract_vendor(),
infer_question_prefaces(),
set_data_name(),
set_dataset_metadata(),
set_field_dates(),
set_field_period(),
set_higher_is(),
set_missing_codes(),
set_question_preface(),
set_reverse_coded(),
set_sata(),
set_survey_name(),
set_universe(),
set_val_labels(),
set_var_extra(),
set_var_label(),
set_var_note(),
set_vendor(),
survey_metadata(),
survey_weighting_history()
Examples
d <- as_survey(
gss_2024,
ids = vpsu,
weights = wtssps,
strata = vstrat,
nest = TRUE
)
d <- set_var_extra(d, age = list(role = "demographic"))
extract_var_extra(d, age)
#> $age
#> $age$role
#> [1] "demographic"
#>
#>
extract_var_extra(d, age, format = "data_frame")
#> # A tibble: 1 × 3
#> variable key value
#> <chr> <chr> <list>
#> 1 age role <chr [1]>
