Skip to content

Instantly share code, notes, and snippets.

@erinshellman
Last active August 29, 2015 14:01
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 erinshellman/815a6c4323e727703d41 to your computer and use it in GitHub Desktop.
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.
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)
}
@erinshellman
Copy link
Author

I wrote this to keep R requirements up to date when working on a collaborative project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment