Last active
August 29, 2015 14:01
-
-
Save erinshellman/815a6c4323e727703d41 to your computer and use it in GitHub Desktop.
A helper script in the spirit of Python's "requirements" file. Run when beginning a project to load up all requirements, or install them if missing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libs = c('arm', | |
'biglm', | |
'car', | |
'doParallel', | |
'dplyr', | |
'gclus', | |
'ggplot2', | |
'gplots', | |
'ggthemes', | |
'lpSolveAPI', | |
'lpSolve', | |
'lubridate', | |
'MDPtoolbox', | |
'plyr', | |
'reshape2', | |
'scales', | |
'stringr') | |
for (i in 1:length(libs)) { | |
lib = libs[i] | |
# Install packages if needed | |
if (!lib %in% installed.packages()) { | |
print(paste('Installing required library ', lib, sep = '')) | |
install.packages(lib, dependencies = TRUE) | |
} | |
# Load package | |
require(lib, character.only = TRUE) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote this to keep R requirements up to date when working on a collaborative project.