Download a file from HTTPS using download.file()

后端 未结 9 1631
庸人自扰
庸人自扰 2020-11-28 07:38

I would like to read online data to R using download.file() as shown below.

URL <- \"https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fs         


        
9条回答
  •  感动是毒
    2020-11-28 08:09

    Here's an update as of Nov 2014. I find that setting method='curl' did the trick for me (while method='auto', does not).

    For example:

    # does not work
    download.file(url='https://s3.amazonaws.com/tripdata/201307-citibike-tripdata.zip',
                  destfile='localfile.zip')
    
    # does not work. this appears to be the default anyway
    download.file(url='https://s3.amazonaws.com/tripdata/201307-citibike-tripdata.zip',
                  destfile='localfile.zip', method='auto')
    
    # works!
    download.file(url='https://s3.amazonaws.com/tripdata/201307-citibike-tripdata.zip',
                  destfile='localfile.zip', method='curl')
    

提交回复
热议问题