Last active
June 15, 2020 14:39
-
-
Save crsh/baff2ba72225989f53d6c7e9eadc441f to your computer and use it in GitHub Desktop.
Function to (install and) load all required packages
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
install_load_all <- function(x) { | |
.install_load_all <- function(x) { | |
if(!require(x, character.only = TRUE)) { | |
install.packages(x, repos = "http://cran.us.r-project.org") | |
library(x, character.only = TRUE) | |
} | |
} | |
invisible(sapply(x, .install_load_all)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment