Skip to content

Instantly share code, notes, and snippets.

@b-kennedy0
Last active May 20, 2020 11: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 b-kennedy0/f534d4acc407f37b8a2e99f8ad2b0f53 to your computer and use it in GitHub Desktop.
Save b-kennedy0/f534d4acc407f37b8a2e99f8ad2b0f53 to your computer and use it in GitHub Desktop.
Tidy code that will: (1) state which packages are required (2) list which ones aren’t already installed. (3) install the new packages. (4) load (library) them. (5) check for updates for all packages.
list_of_packages<-c("tidyr","psych","ggplot2","here")
new.packages <- list_of_packages[!(list_of_packages %in% installed.packages()[,"Package"])]
if(length(new.packages))install.packages(new.packages)
lapply(list_of_packages, library, character.only = TRUE)
update.packages(ask=FALSE, repos = "https://cloud.r-project.org")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment