Skip to content

Instantly share code, notes, and snippets.

@gu-mi
Created May 19, 2014 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gu-mi/05d73cd1b7736f849fe2 to your computer and use it in GitHub Desktop.
Save gu-mi/05d73cd1b7736f849fe2 to your computer and use it in GitHub Desktop.
Detect which packages are not installed, and then install them and load all required packages into session.
# check if you need to install these packages
pkg <- c("RODBC", "ggplot2")
inst <- pkg %in% installed.packages()
# inst
if (length(pkg[!inst]) > 0) {
install.packages(pkg[!inst])
}
# load all required packages into session
lapply(pkg, library, character.only = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment