Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
Created August 19, 2012 13:31
Show Gist options
  • Save reinholdsson/3394814 to your computer and use it in GitHub Desktop.
Save reinholdsson/3394814 to your computer and use it in GitHub Desktop.
Install and/or load packages (add to the munge folder in ProjectTemplate)
load_packages <- function(pkgs, repo = "http://ftp.sunet.se/pub/lang/CRAN/"){
invisible(lapply(pkgs, function(pkg) {
req <- function(x) require(x, character.only = TRUE)
if(!suppressWarnings(req(pkg))){
install.packages(pkg, repos = repo)
req(pkg)
}
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment