Skip to contents

Records whether a higher value is better ("better") or worse ("worse") for one or more variables in a survey design object or data frame. This metadata is used by get_diffs() when show_favorability = TRUE.

Usage

set_higher_is(x, ..., variable = NULL, direction = NULL)

Arguments

x

A survey design object or data.frame.

...

Named arguments where the name is the variable and the value is the direction ("better" or "worse"). Supports Convention 1 (named args: bpxsy1 = "worse") and Convention 2 (named character vector: c(bpxsy1 = "worse", lbxtc = "better")). Mutually exclusive with variable.

variable

character. Variable name(s) — Convention 3 alternative to .... Mutually exclusive with ....

direction

character. Direction value(s) for Convention 3. Must be "better", "worse", or NULL (to remove the attribute). Same length as variable, or NULL to remove.

Value

The modified object, invisibly.

Examples

d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_higher_is(d, bpxsy1 = "worse")
extract_higher_is(d, bpxsy1)
#>  bpxsy1 
#> "worse"