Skip to content

Instantly share code, notes, and snippets.

@dgrapov
Last active December 11, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgrapov/4627994 to your computer and use it in GitHub Desktop.
Save dgrapov/4627994 to your computer and use it in GitHub Desktop.
#load devium (or any other package) from github repo
source.git.hub<-function(url = "https://github.com/dgrapov/devium/tree/master/R")
{
if(require(RCurl)==FALSE){install.packages("RCurl");library(RCurl)} else { library(RCurl)}
#get the names of all scripts to source
obj<-getURL("https://github.com/dgrapov/devium/tree/master/R",ssl.verifypeer=FALSE)
tmp<-strsplit(obj,'href=\"/')
tmp2<-unlist(strsplit(as.character(unlist(tmp)),'class'))
scripts<-gsub("/blob","",gsub('\" ',"",tmp2[grep("dgrapov/devium/blob/master/R/",tmp2)])) # fix formatting
#add http for git hub
scripts<-paste("https://raw.github.com/",scripts,sep="")
sapply(1:length(scripts),function(i)
{
tryCatch( eval( expr = parse( text = getURL(scripts[i],
ssl.verifypeer=FALSE) ),envir=.GlobalEnv),error=function(e){print(paste("can't load:",scripts[i]))})
})
}
source.git.hub()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment