Skip to content

Instantly share code, notes, and snippets.

@fernandomayer
Last active July 17, 2020 11:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save fernandomayer/6158625 to your computer and use it in GitHub Desktop.
Save fernandomayer/6158625 to your computer and use it in GitHub Desktop.
This function allows you to source individual R files from a GitHub repository. Author: Tony Breyal, with contributions from Kay Cichini. Source: http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
source_https <- function(url, ...) {
## Function for sourcing individual R scripts from GitHub
## Author: Tony Breyal
## Contributions: Kay Cichini
## Original URL: http://tonybreyal.wordpress.com/2011/11/24/source_https-sourcing-an-r-script-from-github/
## Load required 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)
})
}
@aw236
Copy link

aw236 commented Oct 21, 2014

I get the following error when trying to use this:
Error in parse(text = getURL(u, followlocation = TRUE, cainfo = system.file("CurlSSL", :
:1:1: unexpected '<'
1: <
^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment