Skip to content

Instantly share code, notes, and snippets.

@tuttinator
Created June 28, 2016 23:25
Show Gist options
  • Save tuttinator/8157122481b6525261146c2d4e3497e6 to your computer and use it in GitHub Desktop.
Save tuttinator/8157122481b6525261146c2d4e3497e6 to your computer and use it in GitHub Desktop.
Install packages on demand
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