Sets missing-value codes for one or more variables. Missing codes are atomic
vectors documenting which data values represent missing data
(e.g., c(Refused = -2L, DontKnow = -1L)).
Arguments
- x
A survey design object or a data frame.
- ...
Named arguments where the name is the variable and the value is a named atomic vector of missing codes. Supports
!!!list splicing.- variable
A character vector of variable names. Use with
codes.- codes
A list of named atomic vectors, one per element of
variable. Whenvariablehas length 1, a bare named atomic vector is also accepted.
Details
Supports Conventions 1, 2, and 3 — see set_var_label() for details on
the calling conventions. For Convention 3 with a single variable, a bare
named atomic vector is accepted in addition to a list.
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_question_preface(),
set_universe(),
set_val_labels(),
set_var_label(),
set_var_note(),
survey_metadata(),
survey_weighting_history()
Examples
d <- as_survey(gss_2024, ids = vpsu, weights = wtssps,
strata = vstrat, nest = TRUE)
d <- set_missing_codes(d, happy = c(Refused = -1L, DK = -2L))
extract_missing_codes(d, happy)
#> $happy
#> Refused DK
#> -1 -2
#>
