Marks one or more columns as survey weights: coerces each to numeric and
attaches the flat metadata schema with type weight. Most surveys carry a
single weight, but several (e.g. per-audience or trimmed variants) are
supported — each selected column is its own group (its own alias), so
alias, alias_name, description and label apply only when a single
column is selected.
Usage
step_set_weight(
x,
.cols,
alias = NULL,
alias_name = NULL,
description = NULL,
label = NULL,
template = "{question}",
snapshot_data = FALSE,
status = TRUE
)Arguments
- x
A
srv_tbl.- .cols
Tidy-select expression picking the weight columns.
- alias
Alias (group key). Defaults to the column name. Single column only.
- alias_name
Human-friendly display name. Single column only.
- description
Overrides the template-parsed description. Single column only.
- label
Sets
attr(col, "label")directly. Single column only.- template
Glue-style template parsed from the label. Default
"{question}".- snapshot_data
Logical. If
TRUE, a snapshot with data is taken; ifFALSE, without data; ifNULL, no snapshot.- status
Logical. If
TRUE, a status message is printed.
Examples
if (FALSE) { # \dontrun{
data("srv_example", package = "g6tr.survey")
x <- srv_example |> step_set_weight("weight")
} # }