From 56065325429ee6fae162f3999fec6c203fffe878 Mon Sep 17 00:00:00 2001 From: cjendres1 Date: Tue, 13 Dec 2016 09:01:11 -0500 Subject: [PATCH] Call download.file explicitly in nhanes() --- DESCRIPTION | 4 ++-- R/nhanes.R | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 92b0189..f98f1a8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/R/nhanes.R b/R/nhanes.R index 1eb63e3..3b96d3c 100644 --- a/R/nhanes.R +++ b/R/nhanes.R @@ -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' @@ -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='')