Skip to content

Instantly share code, notes, and snippets.

@brianspiering
Last active August 29, 2015 13:56
Show Gist options
  • Save brianspiering/9027330 to your computer and use it in GitHub Desktop.
Save brianspiering/9027330 to your computer and use it in GitHub Desktop.
Automatically check and install packages in R
# Setup Packages ---------------------------------------------------------------
# List of packages for session
.packages <- c("devtools", "dplyr", "ggplot2", "markdown")
# Install CRAN packages (if not already installed)
.inst <- .packages %in% installed.packages()
if(length(.packages[!.inst]) > 0) install.packages(.packages[!.inst])
# Load packages for session
lapply(.packages, require, character.only=TRUE)
cat("\014") # clear console
# TODO: support packages from GitHub
# install_github("cowsay", username="SChamberlain")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment