Skip to content

Instantly share code, notes, and snippets.

@geotheory
Last active August 29, 2015 14:26
Show Gist options
  • Save geotheory/6a4ce433c6992e748937 to your computer and use it in GitHub Desktop.
Save geotheory/6a4ce433c6992e748937 to your computer and use it in GitHub Desktop.
Run R code from URL (e.g. Github)
# https://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
source_https <- function(url, ...) {
# load package
require(RCurl)
# parse and evaluate each .R script
sapply(c(url, ...), function(u) {
eval(parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))), envir = .GlobalEnv)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment