Learn R Programming

surveycore (version 0.8.3)

extract_metadata: Extract All Metadata for Variables

Description

Returns a summary of all metadata fields for one or more variables in a survey design object or data frame. Useful for auditing metadata state or building codebooks.

Usage

extract_metadata(x, ..., fill = NULL)

Value

A named list. Each entry is a named list with keys: variable_label, value_labels, question_preface, note, universe, missing_codes, transformations.

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 metadata for all variables. Use tidyselect::any_of() to silently skip missing variable names.

fill

NULL (default) or "include". NULL omits variables that have no metadata in any field; "include" returns all variables regardless.

See Also

Other metadata: classify_question_type(), extract_missing_codes(), extract_question_preface(), extract_sata(), extract_universe(), extract_val_labels(), extract_var_label(), extract_var_note(), infer_question_prefaces(), set_missing_codes(), set_question_preface(), set_sata(), set_universe(), set_val_labels(), set_var_label(), set_var_note(), survey_metadata(), survey_weighting_history()

Examples

Run this code
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_universe(d, ridageyr = "All participants 0+")
extract_metadata(d, ridageyr)
extract_metadata(d, fill = "include")

Run the code above in your browser using DataLab