Skip to content

Instantly share code, notes, and snippets.

@SwampThingPaul
Created February 15, 2020 01:55
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 SwampThingPaul/54a4a22b676553bc8a6fb4c379464995 to your computer and use it in GitHub Desktop.
Save SwampThingPaul/54a4a22b676553bc8a6fb4c379464995 to your computer and use it in GitHub Desktop.
check and install packages
## 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