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.