Last active
November 11, 2016 22:05
-
-
Save ZeccaLehn/ebb03a18e197c44aee11 to your computer and use it in GitHub Desktop.
[R] Check and Load Packages
This file contains hidden or 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
# Allows for install check and automatic download | |
# Note: Rerun line 6 after CTRL + ALT + F10 Restart | |
# Adapted from: http://stackoverflow.com/questions/4090169/elegant-way-to-check-for-missing-packages-and-install-them | |
packages <- c("data.table", "dplyr", "doParallel") | |
packagesCheck <- packages[!(packages %in% installed.packages()[,"Package"])] | |
if(length(packagesCheck)>0) {install.packages(packagesCheck)}; rm(packagesCheck) | |
lapply(packages, function(x) {do.call("require", list(x))}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment