Learn R Programming

surveycore (version 0.8.3)

set_sata: Set SATA (Select-All-That-Apply) Flag

Description

Marks one or more variables as select-all-that-apply (SATA) in a survey design object or a data frame. Unlike the other unified setters (which map variable names to heterogeneous content), set_sata() applies a single logical flag to all listed variables, so it uses a simplified two-convention pattern.

Usage

set_sata(x, ..., variable = NULL, sata = TRUE)

Value

The modified object, invisibly.

Arguments

x

A survey design object or data.frame.

...

<tidy-select> Variables to mark. Supports selection helpers: tidyselect::starts_with(), tidyselect::all_of(), tidyselect::any_of(), etc. Cannot be combined with variable.

variable

character. Alternative programmatic interface: character vector of variable names. Cannot be combined with ....

sata

logical(1). TRUE (default) marks variables as SATA; FALSE removes the SATA flag. NA is not accepted.

Details

Convention A (tidy-select ...) — recommended:

design |> set_sata(news_tv, news_online, news_radio)
design |> set_sata(starts_with("news_"))

Convention B (variable = character vector) — programmatic:

sata_vars <- c("news_tv", "news_online", "news_radio")
design |> set_sata(variable = sata_vars)

Setting sata = FALSE unmarks the listed variables.

See Also

extract_sata() to retrieve SATA flags

Other metadata: classify_question_type(), extract_metadata(), 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_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_sata(d, riagendr, ridageyr)
d <- set_sata(d, riagendr, sata = FALSE)

Run the code above in your browser using DataLab