Skip to contents

Returns the direction-of-improvement ("better" or "worse") for one or more variables in a survey design object or data frame. Variables with no direction set return NA_character_.

Usage

extract_higher_is(x, ..., variable = NULL)

Arguments

x

A survey design object or data.frame.

...

<tidy-select> Variables to query. If empty, returns direction for all columns of x. Mutually exclusive with variable.

variable

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

Value

A named character vector. Unset variables return NA_character_. Returns character(0) (named, zero-length) when all specified variables are missing from x.

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" 
extract_higher_is(d)
#>     seqn  sdmvpsu sdmvstra wtmec2yr wtint2yr ridstatr riagendr ridageyr 
#>       NA       NA       NA       NA       NA       NA       NA       NA 
#> ridreth3 indfmpir dmdeduc2   bpxsy1   bpxdi1   bpxpls 
#>       NA       NA       NA  "worse"       NA       NA