Last active
May 10, 2020 18:04
-
-
Save mathzero/d37575dbca2dc87dee14a2ab2df2a8e7 to your computer and use it in GitHub Desktop.
Snippet of code to include at start of a script to install and load any necessary packages
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
### Install packages | |
list.of.packages <- c("citr", "colourpicker", "rcrossref", "jpeg","RCurl") ### add all the packages that are used in your script here | |
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] ### check if they are installed | |
if(length(new.packages)) install.packages(new.packages) ### install any that need installing | |
### Load packages | |
lapply(list.of.packages, require, character.only = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment