Last active
August 29, 2015 14:09
-
-
Save air-drummer/d722484cdec2b7bc8d8b to your computer and use it in GitHub Desktop.
Loading packages in R in one shot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Loading packages in R in one shot | |
load.packages <- function(..., install = TRUE){ | |
reqFun <- function(pack) { | |
if(!suppressWarnings(suppressMessages(require(pack, character.only = TRUE)))) { | |
message(paste0("unable to load package ", pack, | |
": attempting to download & then load")) | |
install.packages(pack) | |
require(pack, character.only = TRUE) | |
} | |
} | |
lapply(..., reqFun) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment