Skip to contents

Returns universe (eligibility) descriptions for one or more variables in a survey design object or data frame.

Usage

extract_universe(x, ..., format = "named_vector", fill = NULL)

Arguments

x

A survey design object or data.frame.

...

<data-masked> Variable names (bare, unquoted). If empty, metadata for all variables is returned.

format

character(1). Output format: "named_vector" (default), "list", or "data_frame".

fill

Scalar or NULL. How to handle variables with no universe: NULL (default) omits them; NA_character_ includes them with NA.

Value

  • "named_vector" (default): named character vector. Empty: character(0).

  • "list": named list of character scalars. Empty: list().

  • "data_frame": tibble with columns variable and universe. Empty: zero-row tibble.

Examples

d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
d <- set_universe(d, ridageyr = "All participants 0+")
extract_universe(d)
#>              ridageyr 
#> "All participants 0+" 
extract_universe(d, ridageyr, format = "data_frame")
#> # A tibble: 1 × 2
#>   variable universe           
#>   <chr>    <chr>              
#> 1 ridageyr All participants 0+