Created
February 15, 2020 01:55
-
-
Save SwampThingPaul/54a4a22b676553bc8a6fb4c379464995 to your computer and use it in GitHub Desktop.
check and install 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
## Function to check and install packages | |
## If package is installed, then the function moves to the next. | |
check.packages <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} | |
pkg=c("lubridate","plyr","reshape","maptools","classInt", | |
"GISTools","zoo","colorRamps","dataRetrieval","leaflet","RcppRoll", | |
"rvest","readr","rjson","kableExtra","knitr") | |
check.packages(pkg) | |
warnings() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment