Prerequisites

The data have been analysed with R (version 4.0.4) and Rstudio (versio 1.4.1106), and the book has been created with bookdown package. The required packages are automatically checked and installed if needed from CRAN.

# Create an auxiliary function for checking if a package is installed,
# install it if it is not, and load the package
# (based on https://gist.github.com/stevenworthington/3178163) 
  ipak <- function(pkg){
    new_pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
    if (length(new_pkg)) 
      install.packages(new_pkg,
                       dependencies = TRUE,
                       repos = "http://cran.us.r-project.org")
    sapply(pkg, require, character.only = TRUE)
  }
  # List of packages 
  pkg <- c("tidyverse",
           "sf", 
           "sp",
           "gstat"
           )
  # Check and install
  ipak(pkg)
# You may also need to install the following packages

  #install.packages(c("MASS", "StatDA", "NADA", "truncnorm", "units", "leaflet", "ggspatial", "gridExtra", "rgdal"))

R session

# R version 4.0.4 (2021-02-15)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 10 x64 (build 17763)
# 
# Matrix products: default
# 
# locale:
# [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
# [3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
# [5] LC_TIME=English_United Kingdom.1252    
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#  [1] gstat_2.0-7     sp_1.4-5        sf_0.9-8        forcats_0.5.1   stringr_1.4.0   dplyr_1.0.5    
#  [7] purrr_0.3.4     readr_1.4.0     tidyr_1.1.3     tibble_3.1.0    ggplot2_3.3.3   tidyverse_1.3.0
# 
# loaded via a namespace (and not attached):
#   [1] leafem_0.1.3            colorspace_2.0-0        ellipsis_0.3.1          class_7.3-18           
#   [5] leaflet_2.0.4.1         satellite_1.0.2         base64enc_0.1-3         fs_1.5.0               
#   [9] rstudioapi_0.13         proxy_0.4-25            fansi_0.4.2             lubridate_1.7.9.2      
#  [13] xml2_1.3.2              codetools_0.2-18        splines_4.0.4           robustbase_0.93-7      
#  [17] knitr_1.31              jsonlite_1.7.2          broom_0.7.5             cluster_2.1.0          
#  [21] dbplyr_2.1.0            png_0.1-7               shiny_1.6.0             StatDA_1.7.4           
#  [25] compiler_4.0.4          httr_1.4.2              backports_1.2.1         mapview_2.9.0          
#  [29] assertthat_0.2.1        Matrix_1.3-2            fastmap_1.1.0           cli_2.3.1              
#  [33] later_1.1.0.1           htmltools_0.5.1.1       tools_4.0.4             gtable_0.3.0           
#  [37] glue_1.4.2              Rcpp_1.0.6              cellranger_1.1.0        jquerylib_0.1.3        
#  [41] raster_3.4-5            vctrs_0.3.6             sgeostat_1.0-27         nlme_3.1-152           
#  [45] crosstalk_1.1.1         xfun_0.22               rvest_1.0.0             mime_0.10              
#  [49] miniUI_0.1.1.1          lifecycle_1.0.0         DEoptimR_1.0-8          zoo_1.8-9              
#  [53] MASS_7.3-53             scales_1.1.1            hms_1.0.0               promises_1.2.0.1       
#  [57] yaml_2.2.1              MBA_0.0-9               NADA_1.6-1.1            sass_0.3.1             
#  [61] stringi_1.5.3           e1071_1.7-6             RandomFieldsUtils_0.5.3 manipulateWidget_0.10.1
#  [65] intervals_0.15.2        rlang_0.4.10            pkgconfig_2.0.3         rgl_0.105.22           
#  [69] evaluate_0.14           lattice_0.20-41         htmlwidgets_1.5.3       tidyselect_1.1.0       
#  [73] magrittr_2.0.1          bookdown_0.21           R6_2.5.0                generics_0.1.0         
#  [77] DBI_1.1.1               pillar_1.5.1            haven_2.3.1             withr_2.4.1            
#  [81] mgcv_1.8-34             xts_0.12.1              units_0.7-1             survival_3.2-10        
#  [85] spacetime_1.2-4         modelr_0.1.8            crayon_1.4.1            KernSmooth_2.23-18     
#  [89] utf8_1.2.1              rmarkdown_2.7           geoR_1.8-1              RandomFields_3.3.8     
#  [93] grid_4.0.4              readxl_1.3.1            FNN_1.1.3               splancs_2.01-40        
#  [97] reprex_1.0.0            digest_0.6.27           classInt_0.4-3          webshot_0.5.2          
# [101] xtable_1.8-4            httpuv_1.5.5            stats4_4.0.4            munsell_0.5.0          
# [105] bslib_0.2.4             tcltk_4.0.4