Skip to content

Instantly share code, notes, and snippets.

@mberneaud
Created May 27, 2016 13:36
Show Gist options
  • Save mberneaud/0cc1d5f237740f789705df6768fc1568 to your computer and use it in GitHub Desktop.
Save mberneaud/0cc1d5f237740f789705df6768fc1568 to your computer and use it in GitHub Desktop.
function used to source R scripts from GitHub. Practical so source R files from within an AWS instance
# Credit for this function goes to Tony Breyal, who shared it on his blog
# 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)
})
}
# Example
source_https("https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/bingSearchXScraper/bingSearchXScraper.R",
"https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/htmlToText/htmlToText.R")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment