Looks up the plain-language CDC description for each column in a NHANES
data frame and stores it as an "label" attribute on the column.
Hmisc reads these attributes automatically in describe,
Hmisc::summary(), Hmisc::html(), and other label-aware
functions, so labelling once makes descriptions available everywhere.
Arguments
- x
A data frame of NHANES data, typically from
nhanes_download_analyte.- descriptions
Optional lookup for variable descriptions. May be:
NULL(default): descriptions are loaded from the locally cached variable catalog. Run anynhanes_search_variablescall first to populate the cache.A
data.framewith columnsvariable_nameandvariable_desc, such as the output ofnhanes_search_variables.A named character vector mapping variable names to descriptions.
Value
x with "label" attributes set on each column that
could be matched to a CDC description. Columns with no catalog match are
returned unchanged.
See also
NH_describe for a one-step labelled describe;
nhanes_search_variables to browse the variable catalog;
label for the Hmisc label convention.
Examples
# \donttest{
tc <- nhanes_download_analyte("total cholesterol", "2015-2016")
#> Found 6 unique variables matching "total cholesterol".
#> Warning: Both "2017-2018" and "2017-2020" are present. The 2017-2018 participants are
#> included in the 2017-2020 pandemic-adjusted file -- use one or the other in
#> pooled analyses to avoid double-counting.
#> Loading cached TCHOL_I for 2015-2016
tc <- NH_label(tc)
# CDC descriptions now appear in all Hmisc label-aware output
invisible(Hmisc::describe(tc))
# }