Skip to contents

Returns the variable label for a single variable in a survey design object, or NULL if no label has been set.

Usage

extract_var_label(x, var)

Arguments

x

A survey design object (survey_taylor, survey_replicate, or survey_twophase).

var

<data-masked> Variable name (bare, unquoted).

Value

A character string, or NULL if no label has been set.

Examples

# nhanes_2017 carries haven-style labels auto-extracted by as_survey()
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
               strata = sdmvstra, nest = TRUE)
extract_var_label(d, riagendr)   # "Gender"
#> [1] "Gender"
extract_var_label(d, ridageyr)   # "Age in years at screening"
#> [1] "Age in years at screening"