Learn R Programming

nhanesA (version 1.1)

nhanes: Download an NHANES table and return as a data frame.

Description

Use to download NHANES data tables that are in SAS format.

Usage

nhanes(
  nh_table,
  includelabels = FALSE,
  translated = TRUE,
  cleanse_numeric = FALSE,
  nchar = 128,
  adjust_timeout = TRUE
)

Value

The table is returned as a data frame.

Arguments

nh_table

The name of the specific table to retrieve.

includelabels

If TRUE, then include SAS labels as variable attribute (default = FALSE).

translated

translated whether the variables are translated.

cleanse_numeric

Logical flag. If TRUE, some special codes in numeric variables, such as ‘Refused’ and ‘Don't know’ will be converted to NA.

nchar

Maximum length of translated string (default = 128). Ignored if translated=FALSE.

adjust_timeout

Typically a logical flag indicating whether the default download.file timeout option should be adjusted by taking into account the size of the file to be downloaded, as reported by the server. The value can also be a positive numeric value, in which case it is used as a further multiplicative factor for the default calculation.

Details

Downloads a table from the NHANES website as is, i.e. in its entirety with no modification or cleansing. 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 data). NHANES tables are stored in SAS '.XPT' format but are imported as a data frame. The nhanes function cannot be used to import limited access data.

Examples

Run this code
bpx_e = nhanes('BPX_E')
dim(bpx_e)
folate_f = nhanes('FOLATE_F', includelabels = TRUE)
dim(folate_f)

Run the code above in your browser using DataLab