Skip to content

Commit

Permalink
Call download.file explicitly in nhanes()
Browse files Browse the repository at this point in the history
  • Loading branch information
cjendres1 committed Dec 13, 2016
1 parent d8b170e commit 5606532
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: nhanesA
Version: 0.6.4.3.2
Date: 2016-12-09
Version: 0.6.4.3.3
Date: 2016-12-13
Title: NHANES Data Retrieval
Author: Christopher Endres
Maintainer: Christopher Endres <[email protected]>
Expand Down
7 changes: 5 additions & 2 deletions R/nhanes.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#nhanesA - retrieve data from the CDC NHANES repository
nhanesURL <- 'http://wwwn.cdc.gov/Nchs/Nhanes/'
nhanesURL <- 'https://wwwn.cdc.gov/Nchs/Nhanes/'
varURL <- 'https://wwwn.cdc.gov/Nchs/Nhanes/search/variablelist.aspx'
dataURL <- 'https://wwwn.cdc.gov/Nchs/Nhanes/search/DataPage.aspx'

Expand Down Expand Up @@ -255,7 +255,10 @@ nhanes <- function(nh_table) {
nht <- tryCatch({
nh_year <- .get_year_from_nh_table(nh_table)
url <- str_c(nhanesURL, nh_year, '/', nh_table, '.XPT', collapse='')
return(sasxport.get(url, lowernames=FALSE))

tf <- tempfile()
download.file(url, tf, mode = "wb", quiet = TRUE)
return(sasxport.get(tf, lowernames=FALSE))
},
error = function(cond) {
message(paste("Data set ", nh_table, " is not available"), collapse='')
Expand Down

0 comments on commit 5606532

Please sign in to comment.