Skip to content

Instantly share code, notes, and snippets.

@crsh
Last active June 15, 2020 14:39
Show Gist options
  • Save crsh/baff2ba72225989f53d6c7e9eadc441f to your computer and use it in GitHub Desktop.
Save crsh/baff2ba72225989f53d6c7e9eadc441f to your computer and use it in GitHub Desktop.
Function to (install and) load all required packages
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