Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active August 29, 2015 14:24
Show Gist options
  • Save ZeccaLehn/acfbe4908148052b9e67 to your computer and use it in GitHub Desktop.
Save ZeccaLehn/acfbe4908148052b9e67 to your computer and use it in GitHub Desktop.
[R] Load and Reload Libraries after Restart with runLib().
packages <- c("data.table", "dplyr", "doParallel") # List of libraries
runLib <- function(packages = packages) {
packagesCheck <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(packagesCheck)) {install.packages(packagesCheck)}; rm(packagesCheck)
lapply(packages, function(x) {do.call("require", list(x))})
}
runLib(packages) # Rerun this line after RESTART in R and add packages as needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment