Skip to content

Instantly share code, notes, and snippets.

@gimoya
Created January 1, 2012 13:31
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 gimoya/1547338 to your computer and use it in GitHub Desktop.
Save gimoya/1547338 to your computer and use it in GitHub Desktop.
Function to source all functions from a R github-repository
fun_install_github <- function (repo = "theBioBucket-Archives",
username = "gimoya",
branch = "master")
{require(RCurl)
message("\nInstalling ", repo, " R-functions from user ", username)
name <- paste(username, "-", repo, sep = "")
url <- paste("https://github.com/", username, "/", repo,
sep = "")
zip_url <- paste("https://nodeload.github.com/", username,
"/", repo, "/zipball/", branch, sep = "")
src <- file.path(tempdir(), paste(name, ".zip", sep = ""))
content <- getBinaryURL(zip_url, .opts = list(followlocation = TRUE,
ssl.verifypeer = FALSE))
writeBin(content, src)
on.exit(unlink(src), add = TRUE)
repo_name <- basename(as.character(unzip(src, list = TRUE)$Name[1]))
out_path <- file.path(tempdir(), repo_name)
unzip(src, exdir = tempdir())
on.exit(unlink(out_path), add = TRUE)
fun.path <- dir(paste(out_path, "/R/Functions/", sep = ""), full.names = T)
for (i in 1:length(fun.path)) {
source(fun.path[i])
cat("\n Sourcing function: ", dir(paste(out_path, "/R/Functions/", sep = ""))[i])}
cat("\n")
}
fun_install_github()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment