r - Download a file from HTTPS using download.file() -
i read online data r using download.file()
shown below.
url <- "https://d396qusza40orc.cloudfront.net/getdata%2fdata%2fss06hid.csv" download.file(url, destfile = "./data/data.csv", method="curl")
someone suggested me add line setinternet2(true)
, still doesn't work.
the error is:
warning messages: 1: running command 'curl "https://d396qusza40orc.cloudfront.net/getdata%2fdata%2fss06hid.csv" -o "./data/data.csv"' had status 127 2: in download.file(url, destfile = "./data/data.csv", method = "curl", : download had nonzero exit status
appreciate help.
it might easiest try rcurl package. install package , try following:
# install.packages("rcurl") library(rcurl) url <- "https://d396qusza40orc.cloudfront.net/getdata%2fdata%2fss06hid.csv" x <- geturl(url) ## or ## x <- geturl(url, ssl.verifypeer = false) out <- read.csv(textconnection(x)) head(out[1:6]) # rt serialno division puma region st # 1 h 186 8 700 4 16 # 2 h 306 8 700 4 16 # 3 h 395 8 100 4 16 # 4 h 506 8 700 4 16 # 5 h 835 8 800 4 16 # 6 h 989 8 700 4 16 dim(out) # [1] 6496 188 download.file("https://d396qusza40orc.cloudfront.net/getdata%2fdata%2fss06hid.csv",destfile="reviews.csv",method="libcurl")
Comments
Post a Comment