The package for O'Reily's new Learning R book (called "learningr") does not work in R v3. Fortunately, the dataset I want from the package is on the package's Github page here called english_monarchs.rda.
However, for the life of me I cannot figure out how to download the rda file. This is my best attempt:
> library(RCurl)
>
> x <- getURL("https://github.com/richierocks/learningr/blob/master/data/english_monarchs.rda"); x
[1] "\n\n\n<!DOCTYPE html>\n<html>\n <head prefix=\"og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# githubog: http://ogp.me/ns/fb/githubog#\">\n <meta charset='utf-8'>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <title>learningr/data/english_monarchs.rda at master · richierocks/learningr · GitHub</title>\n <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"/opensearch.xml\" title=\"GitHub\" />
It goes on like this through all the html of the page, I cut it short since you get the point. I get the html but not the file itself.
Any help would be much appreciated.
Did you try clicking on "View Raw"?
There may be a better way to do this, but if you want to do this entirely automatically/within R:
library(RCurl)
## paste URL to make it easier to read code (cosmetic!)
dat_url <- paste0("https://raw.github.com/richierocks/",
"learningr/master/data/english_monarchs.rda")
f <- getBinaryURL()
L <- load(rawConnection(f))
(To deal with the redirection, I downloaded the file in Firefox and then asked Firefox to copy the actual download link.)
By the way, are you sure learningr doesn't work with R 3.+ ? I followed the installation instructions at https://github.com/richierocks/learningr/blob/master/README.md with R-devel and they seemed to work fine ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With