Returns full NHANES codebook including Variable Name, SAS Label, English Text, Target, and Value distribution.

nhanesCodebook(nh_table, colname = NULL, dxa = FALSE)

Arguments

nh_table

The name of the NHANES table that contains the desired variable.

colname

The name of the table column (variable).

dxa

If TRUE then the 2005-2006 DXA codebook will be used (default=FALSE).

Value

The codebook is returned as a list object. Returns NULL upon error.

Details

Each NHANES variable has a codebook that provides a basic description as well as the distribution or range of values. This function returns the full codebook information for the selected variable. If the environment variable NHANES_TABLE_BASE was set during startup, the value of this variable is used as the base URL instead of https://wwwn.cdc.gov (this allows the use of a local or alternative mirror of the CDC documentation).

Examples

# \donttest{
## May fail if CDC website is unavailable
try({
    nhanesCodebook('AUX_D', 'AUQ020D') |> print()
    nhanesCodebook('BPX_J', 'BPACSZ') |> print()
    bpx_code = nhanesCodebook('BPX_J')
    length(bpx_code)
})
#> $`Variable Name:`
#> [1] "AUQ020D"
#> 
#> $`SAS Label:`
#> [1] "Earache Last 24 Hours, Left?"
#> 
#> $`English Text:`
#> [1] "Have you had an earache in left ear in the last 24 hours?"
#> 
#> $`Target:`
#> [1] "Both males and females 12 YEARS -\r 19 YEARS"
#> 
#> $`Target:`
#> [1] "Both males and females 70 YEARS -\r 150 YEARS"
#> 
#> $AUQ020D
#> # A tibble: 4 × 5
#>   `Code or Value` `Value Description`     Count Cumulative `Skip to Item`
#>   <chr>           <chr>                   <int>      <int> <lgl>         
#> 1 1               Yes (checkbox checked)     11         11 NA            
#> 2 2               No (checkbox unchecked)   342        353 NA            
#> 3 9               Don't know                  1        354 NA            
#> 4 .               Missing                  2680       3034 NA            
#> 
#> $`Variable Name:`
#> [1] "BPACSZ"
#> 
#> $`SAS Label:`
#> [1] "Coded cuff size"
#> 
#> $`English Text:`
#> [1] "Cuff size (cm) (width X length)"
#> 
#> $`Target:`
#> [1] "Both males and females 8 YEARS -\r 150 YEARS"
#> 
#> $BPACSZ
#> # A tibble: 6 × 5
#>   `Code or Value` `Value Description` Count Cumulative `Skip to Item`
#>   <chr>           <chr>               <int>      <int> <lgl>         
#> 1 1               Infant (6X12)           0          0 NA            
#> 2 2               Child (9X17)          408        408 NA            
#> 3 3               Adult (12X22)        2245       2653 NA            
#> 4 4               Large (15X32)        3123       5776 NA            
#> 5 5               Thigh (18X35)        1036       6812 NA            
#> 6 .               Missing              1892       8704 NA            
#> 
#> [1] 21
# }