Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206235

load(url(....)) vs download.file in R. Why the latter doesn't work when downloading .Rdata files?

$
0
0

I'm reading some of my old R notes and I'm faced with something that make things confusing to me. Here you can find a dummy database with .Rdata extension.

When I use load + url the database is downloaded and read properly:

load(url("http://d396qusza40orc.cloudfront.net/statistics%2Fproject%2Fgss.Rdata"))
str(gss)

But when I try to accomplish same thing using download.file and then readRDS I got an error:

URLtest <- "http://d396qusza40orc.cloudfront.net/statistics%2Fproject%2Fgss.Rdata"
download.file(URLtest,"myfile", method="curl")
readRDS("myfile)
Error in readRDS ("myfile"): unknown input format

The reason I called readRDS can be found here.

So if load is not advised because its side effects (such as silently overwriting files) why does it work in cases like this?

Any reference and comment will be much appreciated.


Viewing all articles
Browse latest Browse all 206235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>