[R-pkg-devel] download.file and https
Joshua Ulrich
josh.m.ulrich at gmail.com
Fri Jul 3 05:07:29 CEST 2015
Hi Paul,
On Thu, Jul 2, 2015 at 9:46 PM, Paul Gilbert <pgilbert902 at gmail.com> wrote:
> (This problem with download.file() affects quantmod, and possibly several
> other packages. e.g. getSymbols('M2',src='FRED') fails.)
>
Thanks for the note. I'm aware of this, and actually wanted to ask
this list what the "best practice" was for downloading files from
https URLs.
> I think the St Louis Fed has moved to using https for connections, and I
> believe all the US government web sites are doing this. An http request is
> automatically switched to https. The default download.file method does not
> seem to handle this, but method="wget" does:
>
IIUC, only if your system has wget installed and it is on the search
path. Another user has suggested setting method="curl", but that has
the same limitations. I could use RCurl to access these files from
FRED, but I'd prefer a solution that doesn't require an additional
package dependency, if possible.
I don't have a lot of experience with downloading from https URLs in R
(especially on Windows) so I would really appreciate some pointers on
how best to handle this.
>> tmp <- tempfile()
>>
>> download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
>> destfile = tmp)
> trying URL
> 'http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv'
> Error in
> download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
> :
> cannot open URL
> 'http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv'
>>
>>
>>
>> download.file("http://research.stlouisfed.org/fred2/series/M2/downloaddata/M2.csv",
>> destfile = tmp, method="wget")
<snip wget output>
> [34519]
>
> Paul
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
More information about the R-package-devel
mailing list