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
Hmisc::describe(tc)
#> tc
#>
#> 4 Variables 8021 Observations
#> --------------------------------------------------------------------------------
#> SEQN : Respondent sequence number
#> n missing distinct
#> 8021 0 8021
#>
#> lowest : 83732 83733 83734 83735 83736, highest: 93697 93699 93700 93701 93702
#> --------------------------------------------------------------------------------
#> LBXTC : Total Cholesterol (mg/dL)
#> n missing distinct Info Mean pMedian Gmd .05
#> 7256 765 257 1 180.3 178 45.47 122
#> .10 .25 .50 .75 .90 .95
#> 132 150 176 204 234 254
#>
#> lowest : 77 80 81 84 85, highest: 393 415 433 540 545
#> --------------------------------------------------------------------------------
#> LBDTCSI : Total Cholesterol( mmol/L)
#> n missing distinct Info Mean pMedian Gmd .05
#> 7256 765 257 1 4.661 4.6 1.176 3.15
#> .10 .25 .50 .75 .90 .95
#> 3.41 3.88 4.55 5.28 6.05 6.57
#>
#> lowest : 1.99 2.07 2.09 2.17 2.2 , highest: 10.16 10.73 11.2 13.96 14.09
#> --------------------------------------------------------------------------------
#> cycle
#> n missing distinct value
#> 8021 0 1 2015-2016
#>
#> Value 2015-2016
#> Frequency 8021
#> Proportion 1
#> --------------------------------------------------------------------------------
Hmisc::html(Hmisc::describe(tc))
# }