Skip to content

Instantly share code, notes, and snippets.

@dpritchard
dpritchard / ipak.R
Last active August 7, 2016 23:01 — forked from stevenworthington/ipak.R
Install and (optionally) load multiple R packages at once
# ipak function: install and load multiple R packages.
# Check to see if packages are installed. Install them if they are not.
# Optionally, load them into the R session.
ipak <- function(pkg, load = FALSE){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg)) {
install.packages(new.pkg, dependencies = TRUE)
}
update.packages(ask = FALSE)