-
Notifications
You must be signed in to change notification settings - Fork 3
/
Installing_R_libraries.R
28 lines (23 loc) · 1.28 KB
/
Installing_R_libraries.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
# Installing R libraries to run rimrep-examples repository
#
# `checking_libraries` function checks that all R libraries used in the
# rimrep-examples repository are in fact installed in your local machine. If
# any libraries are missing, it will install them automatically.
#
checking_libraries <- function(){
#List of packages needed to run all notebooks in repository
packages_required <- c("arrow", "tidyverse", "wkb", "sf", "rnaturalearth",
"leaflet", "tictoc", "DT", "wordcloud2", "janitor",
"magrittr", "tm", "httr", "httr2", "terra", "tcltk",
"usethis", "tidyterra")
#Checking packages installed in local machine
packages_local <- installed.packages()
#Find if there are any packages used in repository missing in local machine
packages_needed <- packages_required[!packages_required %in% packages_local]
#If packages are missing, install them
if(length(packages_needed)){
print(paste0("The following packages will be installed: ", paste(packages_needed, collapse = ", ")))
install.packages(packages_needed)
#If no packages are missing, print message
}else{print("All packages needed to run notebooks in this repository are available in your machine.")}
}