Last active
September 1, 2016 21:34
-
-
Save wmcraver/c175b8e011389a8e5b8f671c3671273e to your computer and use it in GitHub Desktop.
Checks for package installation. If the package does not exist, it installs them.
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
needed = c("lubridate", "dplyr", "data.table", "stringr") | |
is.installed = function(pkg){ | |
is.element(pkg, installed.packages()[,1]) | |
} | |
# For loop to run through each of the packages | |
for (p in 1:length(needed)){ | |
ifelse(!is.installed(needed[p]), install.packages(needed[p], dependencies = T), print(paste(needed[p], " is already installed", sep = ""))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment