Downloads an NHANES table from a URL and returns it as a data frame.
nhanesFromURL(
url,
translated = TRUE,
cleanse_numeric = TRUE,
nchar = 128,
adjust_timeout = TRUE
)
URL of XPT file to be downloaded.
logical, whether variable codes should be translated
Logical flag. If TRUE
, some special
codes in numeric variables, such as ‘Refused’ and
‘Don't know’ will be converted to NA
.
integer, labels are truncated after this
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.
A data frame containing the data in the XPT file avalable at the URL.
This function downloads a table from the NHANES website using its
URL. It is similar to nhanes
, except that it
requires the URL to be explicitly specified, and does not try to
infer it from the table name. It also performs some limited
cleansing of the data by default.
The URL may be completely specified, but the initial standard
prefix "https://wwwn.cdc.gov"
may be optionally
dropped. More precisely, if the URL starts with "/nchs/"
,
then the prefix is automatically added. It is possible to override
the default prefix by setting the environment variable
NHANES_TABLE_BASE
(this allows the use of a local or
alternative mirror of the CDC data).
vix_e = nhanesFromURL("https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2007/DataFiles/VIX_E.xpt")
bpx_e = nhanesFromURL("/Nchs/Data/Nhanes/Public/2007/DataFiles/BPX_E.xpt", translated = FALSE)
dim(bpx_e)
#> [1] 9762 27