trying to download this zipped file from the cdc with R. it works fine from firefox.. so i tried setInternet2(TRUE)
right away, but that still didn't work..
in every case below, i get:
z<-unzip(tf)
Warning message:
In unzip(tf) : zip file is corrupt
here are the starting two lines for all of my attempts--
fn <- 'ftp://ftp.cdc.gov/pub/health_statistics/nchs/datasets/dvs/natality/nat2012us.zip'
tf <- tempfile() ; td <- tempdir()
and here's what i tried:
# fails
download.file(fn,tf,mode='wb')
z <- unzip( tf , exdir = td )
# fails
setInternet2(TRUE)
download.file(fn,tf,mode='wb')
z <- unzip( tf , exdir = td )
# fails
download.file(fn,tf,mode='wb',cacheOK=FALSE)
z <- unzip( tf , exdir = td )
# fails
setInternet2(TRUE)
download.file(fn,tf,mode='wb',cacheOK=FALSE)
z <- unzip( tf , exdir = td )
# fails
library(downloader)
download(fn,tf,mode='wb')
z <- unzip( tf , exdir = td )
# fails
library(httr)
resp <- GET(fn)
writeBin(content(resp, "raw"), tf)
# fails
library(RCurl)
x <- getBinaryURL( fn )
writeBin( x , tf )
z <- unzip(tf)
# in every case:
> file.info(tf)$size
[1] 228799759
sorry if it's something stupid