Created
June 28, 2016 23:25
-
-
Save tuttinator/8157122481b6525261146c2d4e3497e6 to your computer and use it in GitHub Desktop.
Install packages on demand
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
required_packages <- c( | |
"dplyr", | |
"readr", | |
"ggplot2", | |
"ggthemes", | |
"futile.logger", | |
"lubridate" | |
) | |
packages_to_install <- required_packages[!(required_packages %in% installed.packages()[, 1])] | |
if (length(packages_to_install) > 0) { | |
install.packages(packages_to_install) | |
} | |
# require the required_packages through sapply | |
sapply(required_packages, library, character.only = TRUE, quietly = TRUE, logical.return = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment