-
Notifications
You must be signed in to change notification settings - Fork 0
/
packageloader.R
50 lines (43 loc) · 1.81 KB
/
packageloader.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# packages to be loaded
packages <- c(
"tidyverse", "broom", "sf", "geosphere", "numbers", "raster", "dplyr", "spData", "remotes",
"RQGIS", "mlr", "vegan", "mapview", "tmap", "leaflet", "ggplot2", "shiny",
"scales", "zoo", "rbenchmark", "tmaptools", "shinyjs",
"mapdeck", "RSAGA", "rgrass7", "link2GI", "osmdata", "parallelMap", "rasterVis",
"arm", "latticeExtra", "grid", "tree", "ranger", "pROC", "maptools",
"randomForest", "doParallel", "kernlab", "shinythemes", "hrbrthemes"
)
# checking which packages have been installed
packs <- lapply(packages, FUN = function(packages) {
do.call("require", list(packages))
})
packs <- unlist(packs, use.names = F)
# generating list of packages yet to be installed
instpacks <- packages[!packs]
# installing all packages that have not yet been installed
lapply(instpacks, FUN = function(instpacks) {
do.call("install.packages", list(instpacks))
})
# spDataLarge is not on CRAN installing from github:
# install.packages("spDataLarge", repos = "https://nowosad.github.io/drat/", type = "source")
# rqgis3 is needed to work with qgis3 and above
# devtools::install_github("jannes-m/RQGIS3")
# should return a vector of TRUE entries - one entry for every successfully loaded package
check <- unlist(lapply(packages, FUN = function(packages) {
do.call("require", list(packages))
}))
failed <- which(check == FALSE)
failed <- packages[failed]
if (identical(character(0), failed)) {
print("All packages loaded successfully.")
} else {
cat("Packages", "\n", failed, "\n", "could not be loaded.")
}
# if this returns TRUE then the installation of all packages was successful
# package tree needs R version 3.6 or higher
# if(!require(installr)) {
# if(!require(installr)) {
# install.packages("installr"); require(installr)
# }
# updateR()
# remotes::install_github("geocompr/geocompkg")