• 1 Packages needed
  • 2 Introduction
  • 3 Data needed
    • 3.1 TreeGOER database
    • 3.2 Bioclimatic conditions at the planting site
    • 3.3 Species list from GlobUNT
  • 4 Create a new data.frame with a wide format from the TreeGOER
    • 4.1 Variables of interest
    • 4.2 Create the new data.frame
  • 5 Filtering for mean annual temperature (BIO01)
    • 5.1 Variable(s) selected for filtering
    • 5.2 Filtering for the baseline climate
    • 5.3 Filtering for the future climate
  • 6 Filtering for three bioclimatic variables
    • 6.1 Variable(s) selected for filtering
    • 6.2 Filtering for the baseline climate
    • 6.3 Filtering for the future climate
  • 7 Filtering for ten bioclimatic variables
    • 7.1 Variable(s) selected for filtering
    • 7.2 Filtering for the baseline climate
    • 7.3 Filtering for the future climate
  • 8 Calculation for single variables
  • 9 A further investigation for single variables
    • 9.1 Concept for calculating the position of the planting site
    • 9.2 New function
    • 9.3 Updated treegoer.widen() function
    • 9.4 Run the analyses
    • 9.5 Cross-checking the analyses
  • 10 Global Biodiversity Standard
  • 11 Session Information

1 Packages needed

library(data.table)
library(readxl)
library(dplyr)
library(BiodiversityR) # to get the treegoer.score() function

2 Introduction

The Tree Globally Observed Environmental Ranges (TreeGOER) database provides information for most known tree species of their environmental ranges for 38 bioclimatic, eight soil and three topographic variables.

In this document, I show how outputs generated by the GlobalUsefulNativeTrees (GlobUNT) online database can be filtered to match bioclimatic conditions of the planting site. Bioclimatic conditions in historical (baseline) and future climates can be sourced from the ClimateForecasts database for 15,504 weather station locations (their distribution is shown in the Zenodo archive or can be inferred via Meteostat).

ClimateForecasts was integrated in version 2024.03 of GlobUNT to filter species for 10 pre-selected variables (nine of these correspond to the variables used in case studies of the Tree Globally Observed Environmental Ranges (TreeGOER), so you could check the justification there).One of the objectives of this document was to provide some details how calculations are done internally.

(In a previous document, I showed how similar analyses could be done with custom functions and bioclimatic conditions obtained from the CitiesGOER database for 52,602 cities.)

The algorithm calculates a Climate Score for each species whereby:

  • Score = 3 means that in ‘environmental space’ the planting site occurs within the 25% - 75% species’s range (as documented in the TreeGOER) for all variables.
  • Score = 2 corresponds to the 5% - 95% species’s range for all variables. This implies that the planting site was outside the 25% - 75% range for some variables.
  • Score = 1 corresponds to the 0% - 100% species’s range for all variables.
  • Score = 0 means that the planting site occurs outside the 0% - 100% species’s range for some of the variables.
  • Score = -1 means that the species is not documented by TreeGOER.

This algorithm is essentially the same as the BIOCLIM model (see Booth et al. 2014 and Booth 2018).

3 Data needed

3.1 TreeGOER database

# treegoer.file <- choose.files() 
# Provide the location where the TreeGOER file 
# (https://zenodo.org/records/10008994: TreeGOER_2023.txt) was downloaded to
treegoer <- fread(treegoer.file, sep="|", encoding="UTF-8")
nrow(treegoer)
## [1] 2450209
length(unique(treegoer$species))
## [1] 48129

3.2 Bioclimatic conditions at the planting site

We will calculate climate scores for the baseline climate and for median climates projected for the 2050s for Shared Socio-economic Pathway 3-7.0. Planting conditions will be inferred from the ClimateForecasts database for Nairobi.

From the ClimateForecasts, GlobUNT or from the Meteostat website, we identify the weather station location of Nairobi / Dagoretti situated near ‘The Great Corner’ in Nairobi.

# Provide the locations where the CitiesGOER files 
# (https://zenodo.org/records/10004594: CitiesGOER_baseline.xlsx and CitiesGOER_2050s_ssp370.xlsx) 
# were downloaded to

site.base <- data.frame(read_excel(baseline.file,
                                   sheet="baseline data",
                                   skip=5))
nrow(site.base) # 15504
## [1] 15504
head(site.base)
##   SEQ    ID     Country Subdivision_filter               Station     Meteostat
## 1   1 40914 Afghanistan      BGL (Baghlan)          Baghlan-Farm station/40914
## 2   2 69728 Afghanistan       PAR (Parwan)   Bagram / ?asan Kh?l station/69728
## 3   3 40945 Afghanistan       BAM (Bamyan)               Bamiyan station/40945
## 4   4 40967 Afghanistan            WAR (-) Behsood / Sar-e Sar?b station/40967
## 5   5 40988 Afghanistan      HEL (Helmand)                  Bust station/40988
## 6   6 40942 Afghanistan            ORU (-)           Chakhcharan station/40942
##       LON     LAT Elevation Bioclimatic bio01 bio02 bio03   bio04 bio05 bio06
## 1 68.6500 36.1000         0        TRUE 17.63 13.55 32.03 1047.75  39.8  -2.5
## 2 69.2700 34.9500      1492        TRUE 15.05 13.82 34.56  974.51  34.9  -5.1
## 3 67.8167 34.8167         0        TRUE  6.72 14.35 36.33  910.77  26.4 -13.1
## 4 67.8500 34.3000      2975        TRUE  1.95 12.98 31.49 1006.61  22.2 -19.0
## 5 64.3667 31.5500         0        TRUE 19.77 16.70 40.05  958.73  41.6  -0.1
## 6 68.4167 33.5333         0        TRUE  7.43 14.51 33.66 1019.83  28.2 -14.9
##   bio07 bio08 bio09 bio10  bio11 bio12 bio13 bio14  bio15 bio16 bio17 bio18
## 1  42.3 11.55 28.85 30.53   4.37   276    66     0  97.07   168     1     2
## 2  40.0  9.23 26.70 26.70   2.35   384    90     3  99.69   244    10    10
## 3  39.5  7.22 16.32 17.55  -5.13   177    38     0  84.89   100     4     6
## 4  41.2 -4.43 13.82 13.82 -11.28   354    85     0  91.60   211     6     6
## 5  41.7 10.20 31.43 31.43   7.75   110    26     0 103.57    75     1     1
## 6  43.1  1.83 17.93 19.30  -6.28   202    39     0  83.58   109     2     3
##   bio19 annualPET aridityIndexThornthwaite climaticMoistureIndex continentality
## 1   108   1464.85                    86.16                 -0.81           29.3
## 2   145   1356.82                    85.13                 -0.72           27.1
## 3    48   1058.66                    83.28                 -0.83           25.6
## 4   124    851.58                    88.35                 -0.58           28.4
## 5    63   1749.44                    93.71                 -0.94           26.6
## 6    86   1112.68                    87.20                 -0.82           29.4
##   embergerQ growingDegDays0 growingDegDays5 maxTempColdest meanTempColdest
## 1     22.36          6460.7          4713.2            7.5             2.5
## 2     33.32          5525.4          3936.2            6.2             0.6
## 3     16.01          2939.9          1790.7           -0.9            -7.0
## 4     31.27          1977.5          1014.0           -8.3           -13.6
## 5      8.97          7244.8          5419.8           12.5             6.2
## 6     16.75          3306.5          2096.3           -3.0            -9.0
##   meanTempWarmest minTempWarmest monthCountByTemp10 PETColdestQuarter
## 1            31.8           23.8                  9             37.40
## 2            27.7           20.5                  7             37.62
## 3            18.6           10.7                  5             23.83
## 4            14.8            7.3                  3             11.55
## 5            32.8           23.9                  9             55.96
## 6            20.4           12.6                  5             22.70
##   PETDriestQuarter PETseasonality PETWarmestQuarter PETWettestQuarter
## 1           193.42        7428.61            217.68             84.27
## 2           191.90        6310.87            191.90             80.99
## 3           146.01        5499.94            158.58             91.34
## 4           138.09        5153.11            138.09             39.09
## 5           237.84        7580.95            237.84             73.10
## 6           152.02        5828.85            166.27             61.33
##   thermicityIndex     MCWD elev  bdod   cec  clay nitrogen phh2o  sand  silt
## 1          378.83 -1195.64  605 146.0 196.9 252.9    141.2  77.9 302.6 444.7
## 2          268.25 -1024.42 1477    NA    NA    NA       NA    NA    NA    NA
## 3           11.25  -881.66 2521 137.8 204.4 273.1    136.7  76.3 391.9 335.2
## 4         -123.50  -629.46 3162 137.2 256.4 311.1    207.1  77.0 315.8 372.9
## 5          420.92 -1639.46  771 147.6 147.5 264.9     65.1  80.5 402.2 332.6
## 6           50.33  -933.63 2170 149.5 177.2 344.3     97.3  78.2 271.3 384.3
##     soc topoWet   tri
## 1  65.1   11.32 41.38
## 2    NA   11.11  1.75
## 3 147.5   10.03 28.50
## 4 100.6   10.01 26.12
## 5  31.4   14.65  3.12
## 6  30.6   11.71  5.62
site.fut <- data.frame(read_excel(future.file,
                                  sheet="data 2050s SSP 3-7.0",
                                  skip=5))
nrow(site.fut) # 15504
## [1] 15504

3.3 Species list from GlobUNT

GlobUNT was filtered for Kenya and trees used as human food. The search resulted in 461 species.

# globunt.file <- choose.files()
globunt.file <- "C:\\Data\\Kenya_GlobUNT_HF_2023-11-15.txt"
globunt <- fread(globunt.file, sep="|", encoding="UTF-8")
nrow(globunt)
## [1] 461

4 Create a new data.frame with a wide format from the TreeGOER

Similar to the case studies of the TreeGOER manuscript (also see the Supplementary Script), a new data.frame is created that documents the ranges for a selected subset of environmental variables.

This database can be created via the BiodiversityR::treegoer.widen() function.

4.1 Variables of interest

Any environmental variable from TreeGOER can be included. Here only variables included in the climate filter of GlobUNT will be included.

focal.vars <- c("bio01", "bio12",
                "climaticMoistureIndex", "monthCountByTemp10", "growingDegDays5",
                "bio05", "bio06", "bio16", "bio17",
                "MCWD")

4.2 Create the new data.frame

treegoer.wide <- treegoer.widen(treegoer=treegoer,
                                species=globunt$Switchboard,
                                filter.vars=focal.vars)
## bio12 - ranges for all species: TRUE 
## climaticMoistureIndex - ranges for all species: TRUE 
## monthCountByTemp10 - ranges for all species: TRUE 
## growingDegDays5 - ranges for all species: TRUE 
## bio05 - ranges for all species: TRUE 
## bio06 - ranges for all species: TRUE 
## bio16 - ranges for all species: TRUE 
## bio17 - ranges for all species: TRUE 
## MCWD - ranges for all species: TRUE
names(treegoer.wide)
##  [1] "species"                    "bio01_n"                   
##  [3] "bio01_MIN"                  "bio01_Q05"                 
##  [5] "bio01_QRT1"                 "bio01_QRT3"                
##  [7] "bio01_Q95"                  "bio01_MAX"                 
##  [9] "bio12_n"                    "bio12_MIN"                 
## [11] "bio12_Q05"                  "bio12_QRT1"                
## [13] "bio12_QRT3"                 "bio12_Q95"                 
## [15] "bio12_MAX"                  "climaticMoistureIndex_n"   
## [17] "climaticMoistureIndex_MIN"  "climaticMoistureIndex_Q05" 
## [19] "climaticMoistureIndex_QRT1" "climaticMoistureIndex_QRT3"
## [21] "climaticMoistureIndex_Q95"  "climaticMoistureIndex_MAX" 
## [23] "monthCountByTemp10_n"       "monthCountByTemp10_MIN"    
## [25] "monthCountByTemp10_Q05"     "monthCountByTemp10_QRT1"   
## [27] "monthCountByTemp10_QRT3"    "monthCountByTemp10_Q95"    
## [29] "monthCountByTemp10_MAX"     "growingDegDays5_n"         
## [31] "growingDegDays5_MIN"        "growingDegDays5_Q05"       
## [33] "growingDegDays5_QRT1"       "growingDegDays5_QRT3"      
## [35] "growingDegDays5_Q95"        "growingDegDays5_MAX"       
## [37] "bio05_n"                    "bio05_MIN"                 
## [39] "bio05_Q05"                  "bio05_QRT1"                
## [41] "bio05_QRT3"                 "bio05_Q95"                 
## [43] "bio05_MAX"                  "bio06_n"                   
## [45] "bio06_MIN"                  "bio06_Q05"                 
## [47] "bio06_QRT1"                 "bio06_QRT3"                
## [49] "bio06_Q95"                  "bio06_MAX"                 
## [51] "bio16_n"                    "bio16_MIN"                 
## [53] "bio16_Q05"                  "bio16_QRT1"                
## [55] "bio16_QRT3"                 "bio16_Q95"                 
## [57] "bio16_MAX"                  "bio17_n"                   
## [59] "bio17_MIN"                  "bio17_Q05"                 
## [61] "bio17_QRT1"                 "bio17_QRT3"                
## [63] "bio17_Q95"                  "bio17_MAX"                 
## [65] "MCWD_n"                     "MCWD_MIN"                  
## [67] "MCWD_Q05"                   "MCWD_QRT1"                 
## [69] "MCWD_QRT3"                  "MCWD_Q95"                  
## [71] "MCWD_MAX"

5 Filtering for mean annual temperature (BIO01)

For the first filtering exercise, we will only use the mean annual temperature (BIO01). This is the same bioclimatic variable that is used in the BGCI Climate Assessment Tool.

Similar to internal calculations in GlobUNT, the list of species is filtered sequentially for the minimum - maximum range (score = 1), 5% - 95% range (score = 2) and 25% - 75% range (score = 3).

5.1 Variable(s) selected for filtering

PL.vars <- "bio01" # PL = Planting Location

5.2 Filtering for the baseline climate

First we filter for the baseline climate, selecting the Dagoretti weather station location in Nairobi …

site.planting <- site.base[site.base$Station == "Nairobi / Dagoretti", ] 
site.planting[, PL.vars]
## [1] 18.93

… and then calculating the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 92
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 132
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 112
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 109
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 92
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                      species climate.score n.TreeGOER
## 3  Acokanthera oppositifolia             3        117
## 4      Acokanthera schimperi             3         56
## 9          Alangium chinense             3        443
## 16         Albizia gummifera             3        331
## 22            Aloe volkensii             3         30
## 24  Anthocleista grandiflora             3        170
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                  species climate.score n.TreeGOER
## 430   Vangueria infausta             3        428
## 432  Vangueria volkensii             3         61
## 433       Vepris nobilis             3        148
## 445    Volkameria glabra             3        215
## 447 Warburgia ugandensis             3         47
## 454    Xymalos monospora             3        321

5.3 Filtering for the future climate

Almost the same script can be used for filter species suitable for the future climate. The only modification is that we now obtain the bioclimatic conditions from the future climate data set.

site.planting <- site.fut[site.fut$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##      [,1]
## [1,]   21

… and then proceed with the same script to calculate the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 134
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 186
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 66
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 59
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 134
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                  species climate.score n.TreeGOER
## 1     Acalypha fruticosa             3        123
## 2        Acalypha ornata             3        240
## 4  Acokanthera schimperi             3         56
## 13 Albizia anthelmintica             3        218
## 16     Albizia gummifera             3        331
## 22        Aloe volkensii             3         30
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                    species climate.score n.TreeGOER
## 447   Warburgia ugandensis             3         47
## 450         Ximenia caffra             3        339
## 455         Zanha africana             3         47
## 456  Zanthoxylum chalybeum             3         42
## 460     Ziziphus mucronata             3       1129
## 461 Ziziphus spina-christi             3        819

6 Filtering for three bioclimatic variables

In the second filtering exercise, we filter the species for three environmental variables, a growing degree days variable (GDD5), the minimum temperature of the coldest month (BIO06) and a moisture index (CMI). Similar environmental variables have been used previously in research on the adaptation of tree species to future climates (see Booth 2016).

The same scripts can be used after selecting the variables.

6.1 Variable(s) selected for filtering

PL.vars <- c("growingDegDays5", "bio06", "climaticMoistureIndex") # PL = Planting Location
PL.vars %in% focal.vars # checking if we had selected these variables earlier
## [1] TRUE TRUE TRUE

6.2 Filtering for the baseline climate

site.planting <- site.base[site.base$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##                          8208
## growingDegDays5       5085.00
## bio06                   11.70
## climaticMoistureIndex   -0.34

… and then calculating the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 30
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 174
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 123
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 118
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 30
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                      species climate.score n.TreeGOER
## 22            Aloe volkensii             3         30
## 24  Anthocleista grandiflora             3        170
## 69      Cassipourea malosana             3        138
## 74          Clausena anisata             3        848
## 112      Croton megalocarpus             3         69
## 145       Drypetes gerrardii             3        132
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                  species climate.score n.TreeGOER
## 371    Solanum giganteum             3        136
## 390    Syzygium cordatum             3        445
## 429  Vangueria apiculata             3         91
## 432  Vangueria volkensii             3         61
## 433       Vepris nobilis             3        148
## 447 Warburgia ugandensis             3         47

6.3 Filtering for the future climate

Again modifying the script is easy, again first selecting the same weather station location:

site.planting <- site.fut[site.fut$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##                          8208
## growingDegDays5       5787.75
## bio06                   13.90
## climaticMoistureIndex   -0.22

… and then proceed with the same script to calculate the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 44
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 211
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 106
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 84
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 44
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                     species climate.score n.TreeGOER
## 2           Acalypha ornata             3        240
## 16        Albizia gummifera             3        331
## 22           Aloe volkensii             3         30
## 40       Bersama abyssinica             3        348
## 47 Brachystegia spiciformis             3        413
## 51       Bridelia micrantha             3        705
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                        species climate.score n.TreeGOER
## 416              Uapaca nitida             3        118
## 429        Vangueria apiculata             3         91
## 431 Vangueria madagascariensis             3        220
## 433             Vepris nobilis             3        148
## 437             Vitex fischeri             3         26
## 447       Warburgia ugandensis             3         47

7 Filtering for ten bioclimatic variables

As you will have expected by now, it is easy to modify the script to include more variables.

Now we analyze for all variables included in GlobUNT.

7.1 Variable(s) selected for filtering

PL.vars <- focal.vars # all the variables

7.2 Filtering for the baseline climate

site.planting <- site.base[site.base$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##                          8208
## bio01                   18.93
## bio12                 1000.00
## climaticMoistureIndex   -0.34
## monthCountByTemp10      12.00
## growingDegDays5       5085.00
## bio05                   27.60
## bio06                   11.70
## bio16                  505.00
## bio17                   69.00
## MCWD                  -418.50

… and then calculating the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 17
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 146
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 144
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 138
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 17
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                      species climate.score n.TreeGOER
## 22            Aloe volkensii             3         30
## 24  Anthocleista grandiflora             3        170
## 69      Cassipourea malosana             3        138
## 112      Croton megalocarpus             3         69
## 145       Drypetes gerrardii             3        132
## 150  Englerophytum natalense             3         88
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                 species climate.score n.TreeGOER
## 317 Psychotria capensis             3        268
## 325      Rhamnus staddo             3         53
## 334  Rotheca myricoides             3        410
## 371   Solanum giganteum             3        136
## 390   Syzygium cordatum             3        445
## 429 Vangueria apiculata             3         91

7.3 Filtering for the future climate

site.planting <- site.fut[site.fut$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##                          8208
## bio01                   21.00
## bio12                 1062.00
## climaticMoistureIndex   -0.22
## monthCountByTemp10      12.00
## growingDegDays5       5787.75
## bio05                   29.10
## bio06                   13.90
## bio16                  509.00
## bio17                   67.00
## MCWD                  -475.70

… and then calculating the climate score

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

nrow(treegoer.scores)
## [1] 461
# breakdown
nrow(treegoer.scores[treegoer.scores$climate.score == 3, ]) # species in the middle of the range
## [1] 21
nrow(treegoer.scores[treegoer.scores$climate.score == 2, ]) # species between 5% - 25% or  75% - 95%
## [1] 187
nrow(treegoer.scores[treegoer.scores$climate.score == 1, ]) # species between 0%-5% or 95% - 100%
## [1] 144
nrow(treegoer.scores[treegoer.scores$climate.score == 0, ]) # species < 0% or > 100% (planting site has novel conditions)
## [1] 93
nrow(treegoer.scores[treegoer.scores$climate.score == -1, ]) # species not documented in TreeGOER
## [1] 16

The following species got the highest scores:

nrow(treegoer.scores[treegoer.scores$climate.score == 3, ])
## [1] 21
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                  species climate.score n.TreeGOER
## 22        Aloe volkensii             3         30
## 51    Bridelia micrantha             3        705
## 74      Clausena anisata             3        848
## 97       Cordia africana             3        181
## 111 Croton macrostachyus             3        234
## 113    Croton sylvaticus             3        193
tail(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                        species climate.score n.TreeGOER
## 323            Rawsonia lucida             3        185
## 382       Strychnos henningsii             3        138
## 395 Tabernaemontana ventricosa             3        111
## 412         Trichilia dregeana             3        128
## 431 Vangueria madagascariensis             3        220
## 433             Vepris nobilis             3        148

8 Calculation for single variables

For the downloaded species list from GlobUNT (available via the button at the bottom of the ‘Show species’ TAB), the climate score is also calculated for each variable separately.

Here I show how these calculations can be repeated for the baseline climate.

site.planting <- site.base[site.base$Station == "Nairobi / Dagoretti", ] 
t(site.planting[, PL.vars])
##                          8208
## bio01                   18.93
## bio12                 1000.00
## climaticMoistureIndex   -0.34
## monthCountByTemp10      12.00
## growingDegDays5       5085.00
## bio05                   27.60
## bio06                   11.70
## bio16                  505.00
## bio17                   69.00
## MCWD                  -418.50

First calculate the climate score again:

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

Next loop through all the selected variables:

for (i in 1:length(PL.vars)) {
# i <- 1  
  PL.var <- PL.vars[i]
  treegoer.scores2 <- treegoer.score(site.species=globunt$Switchboard,
                                     treegoer.wide=treegoer.wide,
                                     filter.vars=PL.var, 
                                     site.data=site.planting)
  treegoer.scores2 <- treegoer.scores2[, c(1:2)]
  names(treegoer.scores2)[2] <- paste0(PL.var, "_score")
  
  treegoer.scores <- left_join(treegoer.scores,
                               treegoer.scores2,
                               by="species")
}

What can be seen now is which variable were critical in obtaining a lower score. For species with the highest scores, they will have obtained the highest score for each individual variable. For species of lower scores, the lower score will have been obtained for at least some of the individual variables.

summary(treegoer.scores[treegoer.scores$climate.score == 3, ])
##    species          climate.score   n.TreeGOER     bio01_score  bio12_score
##  Length:17          Min.   :3     Min.   : 26.0   Min.   :3    Min.   :3   
##  Class :character   1st Qu.:3     1st Qu.: 69.0   1st Qu.:3    1st Qu.:3   
##  Mode  :character   Median :3     Median :132.0   Median :3    Median :3   
##                     Mean   :3     Mean   :161.1   Mean   :3    Mean   :3   
##                     3rd Qu.:3     3rd Qu.:170.0   3rd Qu.:3    3rd Qu.:3   
##                     Max.   :3     Max.   :445.0   Max.   :3    Max.   :3   
##  climaticMoistureIndex_score monthCountByTemp10_score growingDegDays5_score
##  Min.   :3                   Min.   :3                Min.   :3            
##  1st Qu.:3                   1st Qu.:3                1st Qu.:3            
##  Median :3                   Median :3                Median :3            
##  Mean   :3                   Mean   :3                Mean   :3            
##  3rd Qu.:3                   3rd Qu.:3                3rd Qu.:3            
##  Max.   :3                   Max.   :3                Max.   :3            
##   bio05_score  bio06_score  bio16_score  bio17_score   MCWD_score
##  Min.   :3    Min.   :3    Min.   :3    Min.   :3    Min.   :3   
##  1st Qu.:3    1st Qu.:3    1st Qu.:3    1st Qu.:3    1st Qu.:3   
##  Median :3    Median :3    Median :3    Median :3    Median :3   
##  Mean   :3    Mean   :3    Mean   :3    Mean   :3    Mean   :3   
##  3rd Qu.:3    3rd Qu.:3    3rd Qu.:3    3rd Qu.:3    3rd Qu.:3   
##  Max.   :3    Max.   :3    Max.   :3    Max.   :3    Max.   :3
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                      species climate.score n.TreeGOER bio01_score bio12_score
## 22            Aloe volkensii             3         30           3           3
## 24  Anthocleista grandiflora             3        170           3           3
## 69      Cassipourea malosana             3        138           3           3
## 112      Croton megalocarpus             3         69           3           3
## 145       Drypetes gerrardii             3        132           3           3
## 150  Englerophytum natalense             3         88           3           3
##     climaticMoistureIndex_score monthCountByTemp10_score growingDegDays5_score
## 22                            3                        3                     3
## 24                            3                        3                     3
## 69                            3                        3                     3
## 112                           3                        3                     3
## 145                           3                        3                     3
## 150                           3                        3                     3
##     bio05_score bio06_score bio16_score bio17_score MCWD_score
## 22            3           3           3           3          3
## 24            3           3           3           3          3
## 69            3           3           3           3          3
## 112           3           3           3           3          3
## 145           3           3           3           3          3
## 150           3           3           3           3          3
summary(treegoer.scores[treegoer.scores$climate.score == 2, ])
##    species          climate.score   n.TreeGOER        bio01_score   
##  Length:146         Min.   :2     Min.   :    6.00   Min.   :2.000  
##  Class :character   1st Qu.:2     1st Qu.:   83.25   1st Qu.:2.000  
##  Mode  :character   Median :2     Median :  200.50   Median :2.000  
##                     Mean   :2     Mean   :  514.72   Mean   :2.438  
##                     3rd Qu.:2     3rd Qu.:  430.75   3rd Qu.:3.000  
##                     Max.   :2     Max.   :20896.00   Max.   :3.000  
##   bio12_score    climaticMoistureIndex_score monthCountByTemp10_score
##  Min.   :2.000   Min.   :2.000               Min.   :3               
##  1st Qu.:2.000   1st Qu.:2.000               1st Qu.:3               
##  Median :3.000   Median :3.000               Median :3               
##  Mean   :2.548   Mean   :2.582               Mean   :3               
##  3rd Qu.:3.000   3rd Qu.:3.000               3rd Qu.:3               
##  Max.   :3.000   Max.   :3.000               Max.   :3               
##  growingDegDays5_score  bio05_score     bio06_score     bio16_score   
##  Min.   :2.000         Min.   :2.000   Min.   :2.000   Min.   :2.000  
##  1st Qu.:2.000         1st Qu.:2.000   1st Qu.:2.000   1st Qu.:2.000  
##  Median :2.000         Median :3.000   Median :3.000   Median :3.000  
##  Mean   :2.432         Mean   :2.527   Mean   :2.589   Mean   :2.719  
##  3rd Qu.:3.000         3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:3.000  
##  Max.   :3.000         Max.   :3.000   Max.   :3.000   Max.   :3.000  
##   bio17_score      MCWD_score   
##  Min.   :2.000   Min.   :2.000  
##  1st Qu.:2.000   1st Qu.:2.000  
##  Median :3.000   Median :3.000  
##  Mean   :2.664   Mean   :2.541  
##  3rd Qu.:3.000   3rd Qu.:3.000  
##  Max.   :3.000   Max.   :3.000
head(treegoer.scores[treegoer.scores$climate.score == 2, ])
##                  species climate.score n.TreeGOER bio01_score bio12_score
## 1     Acalypha fruticosa             2        123           2           2
## 2        Acalypha ornata             2        240           2           3
## 4  Acokanthera schimperi             2         56           3           3
## 16     Albizia gummifera             2        331           3           2
## 26     Antidesma venosum             2        914           2           3
## 29      Avicennia marina             2       1501           3           3
##    climaticMoistureIndex_score monthCountByTemp10_score growingDegDays5_score
## 1                            2                        3                     2
## 2                            3                        3                     2
## 4                            2                        3                     3
## 16                           2                        3                     3
## 26                           3                        3                     2
## 29                           2                        3                     3
##    bio05_score bio06_score bio16_score bio17_score MCWD_score
## 1            2           3           2           3          2
## 2            2           3           3           2          2
## 4            3           3           2           3          2
## 16           3           3           2           3          3
## 26           2           2           3           2          3
## 29           3           3           3           3          3
summary(treegoer.scores[treegoer.scores$climate.score == 1, ])
##    species          climate.score   n.TreeGOER       bio01_score   
##  Length:144         Min.   :1     Min.   :   13.0   Min.   :1.000  
##  Class :character   1st Qu.:1     1st Qu.:  159.8   1st Qu.:1.000  
##  Mode  :character   Median :1     Median :  342.0   Median :1.000  
##                     Mean   :1     Mean   : 1040.3   Mean   :1.382  
##                     3rd Qu.:1     3rd Qu.:  705.8   3rd Qu.:2.000  
##                     Max.   :1     Max.   :39616.0   Max.   :3.000  
##   bio12_score    climaticMoistureIndex_score monthCountByTemp10_score
##  Min.   :1.000   Min.   :1.000               Min.   :2.000           
##  1st Qu.:2.000   1st Qu.:2.000               1st Qu.:3.000           
##  Median :2.000   Median :2.000               Median :3.000           
##  Mean   :2.097   Mean   :2.153               Mean   :2.993           
##  3rd Qu.:3.000   3rd Qu.:3.000               3rd Qu.:3.000           
##  Max.   :3.000   Max.   :3.000               Max.   :3.000           
##  growingDegDays5_score  bio05_score     bio06_score     bio16_score   
##  Min.   :1.000         Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:1.000         1st Qu.:1.000   1st Qu.:2.000   1st Qu.:2.000  
##  Median :1.000         Median :2.000   Median :2.000   Median :2.000  
##  Mean   :1.382         Mean   :1.667   Mean   :2.035   Mean   :2.403  
##  3rd Qu.:2.000         3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:3.000  
##  Max.   :3.000         Max.   :3.000   Max.   :3.000   Max.   :3.000  
##   bio17_score      MCWD_score   
##  Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:1.000  
##  Median :2.000   Median :2.000  
##  Mean   :2.174   Mean   :2.028  
##  3rd Qu.:3.000   3rd Qu.:3.000  
##  Max.   :3.000   Max.   :3.000
head(treegoer.scores[treegoer.scores$climate.score == 1, ])
##                     species climate.score n.TreeGOER bio01_score bio12_score
## 3 Acokanthera oppositifolia             1        117           3           2
## 5        Adansonia digitata             1       2218           1           3
## 6            Adenium obesum             1        594           1           2
## 7   Afrocanthium lactescens             1         52           2           3
## 8        Afzelia quanzensis             1        252           1           3
## 9         Alangium chinense             1        443           3           2
##   climaticMoistureIndex_score monthCountByTemp10_score growingDegDays5_score
## 3                           2                        3                     3
## 5                           2                        3                     1
## 6                           2                        3                     1
## 7                           3                        3                     2
## 8                           3                        3                     1
## 9                           1                        3                     3
##   bio05_score bio06_score bio16_score bio17_score MCWD_score
## 3           3           1           2           3          2
## 5           1           2           3           1          2
## 6           1           3           2           2          2
## 7           3           3           3           2          1
## 8           1           3           3           2          1
## 9           3           2           2           3          2
summary(treegoer.scores[treegoer.scores$climate.score == 0, ])
##    species          climate.score   n.TreeGOER      bio01_score    
##  Length:138         Min.   :0     Min.   :   1.0   Min.   :0.0000  
##  Class :character   1st Qu.:0     1st Qu.:  22.0   1st Qu.:0.0000  
##  Mode  :character   Median :0     Median :  53.5   Median :0.0000  
##                     Mean   :0     Mean   : 301.1   Mean   :0.3333  
##                     3rd Qu.:0     3rd Qu.: 320.8   3rd Qu.:0.0000  
##                     Max.   :0     Max.   :3499.0   Max.   :3.0000  
##   bio12_score   climaticMoistureIndex_score monthCountByTemp10_score
##  Min.   :0.00   Min.   :0.000               Min.   :3               
##  1st Qu.:1.00   1st Qu.:1.000               1st Qu.:3               
##  Median :2.00   Median :2.000               Median :3               
##  Mean   :1.87   Mean   :1.862               Mean   :3               
##  3rd Qu.:3.00   3rd Qu.:3.000               3rd Qu.:3               
##  Max.   :3.00   Max.   :3.000               Max.   :3               
##  growingDegDays5_score  bio05_score      bio06_score     bio16_score   
##  Min.   :0.0000        Min.   :0.0000   Min.   :0.000   Min.   :0.000  
##  1st Qu.:0.0000        1st Qu.:0.0000   1st Qu.:0.000   1st Qu.:2.000  
##  Median :0.0000        Median :0.0000   Median :1.000   Median :2.000  
##  Mean   :0.3333        Mean   :0.6739   Mean   :1.007   Mean   :2.123  
##  3rd Qu.:0.0000        3rd Qu.:1.0000   3rd Qu.:2.000   3rd Qu.:3.000  
##  Max.   :3.0000        Max.   :3.0000   Max.   :3.000   Max.   :3.000  
##   bio17_score      MCWD_score   
##  Min.   :0.000   Min.   :0.000  
##  1st Qu.:1.000   1st Qu.:0.000  
##  Median :2.000   Median :1.000  
##  Mean   :1.862   Mean   :1.261  
##  3rd Qu.:3.000   3rd Qu.:2.000  
##  Max.   :3.000   Max.   :3.000
head(treegoer.scores[treegoer.scores$climate.score == 0, ])
##                  species climate.score n.TreeGOER bio01_score bio12_score
## 10 Alangium salviifolium             0         48           0           2
## 15    Albizia glaberrima             0        365           0           3
## 19         Albizia zygia             0       1198           0           2
## 25    Antiaris toxicaria             0       1150           0           2
## 28   Asteranthe asterias             0         73           0           2
## 32  Balanites aegyptiaca             0       3499           0           2
##    climaticMoistureIndex_score monthCountByTemp10_score growingDegDays5_score
## 10                           3                        3                     0
## 15                           3                        3                     0
## 19                           3                        3                     0
## 25                           3                        3                     0
## 28                           2                        3                     0
## 32                           1                        3                     0
##    bio05_score bio06_score bio16_score bio17_score MCWD_score
## 10           0           2           2           3          2
## 15           0           1           3           2          3
## 19           0           1           3           2          3
## 25           0           1           3           2          3
## 28           0           0           3           3          3
## 32           0           1           2           0          1

9 A further investigation for single variables

In the April 2024 version of GlobUNT, when the user downloads the species list, information is also provided on the position of the planting site with respect to the median and extremes (minimum or maximum) of the species range.

9.1 Concept for calculating the position of the planting site

It may be important to differentiate between situations where the environmental conditions of the planting site are above or below the median of the species range. Where the climate score is zero as a result from encountering novel conditions for annual precipitation (BIO12), it may matter less if the planting site receives a higher amount of rainfall than maximally observed for the species, whereas it may be critical that the site does not receive a lower amount of rainfally than minimally observed for the species. For the maximum temperature of the warmest month, it may especially be critical that not a higher temperature is observed for the planting site, whereas a species maybe can survive in conditions where the maximum temperature is below the minimum observed.

The calculation of the new metric for the position of the planting site is done as follows:

  • For sites where the conditions of the planting location (PL) are above the median, the position is calculated as:

    (PL - MEDIAN) / (MAX - MEDIAN)

  • For sites where the conditions of the planting location (PL) are below the median, the position is calculated as:

    (PL - MEDIAN) / (MEDIAN - MIN)

The sign (positive or negative) will therefore indicate the position (respectively, lower or higher) of the planting site with respect to the median of the species.

The magnitude of the metric will indicate the relative distance of the planting site with respect to the difference between median and extreme. Values that are lower than -1 will indicate novel conditions below the minimum. Values that are above +1 will indicate novel conditions above the maximum.

9.2 New function

The analysis requires a new function treegoer.position(). My plan is to integrate the new function in a next version of the BiodiversityR package. But for the time being, you need to define the functions here.

`treegoer.position` <- function(site.data, treegoer.wide, focal.var) {
  focal.test <- paste0(focal.var, c("_MIN", "_MEDIAN", "_MAX"))
  focal.test <- c("species", focal.test)
  data1 <- treegoer.wide[, ..focal.test]
  names(data1) <- c("species", "MIN", "MEDIAN", "MAX")
  
  data1$position <-  as.numeric(site.data[, focal.var]) - data1$MEDIAN
  
  data1$position_score <- ifelse(
    data1$position >= 0,
    data1$position / (data1$MAX - data1$MEDIAN),
    data1$position / (data1$MEDIAN - data1$MIN)
  )
  
  data1$position_score <- round(data1$position_score, 2)
  out.names <- c("species", "position_score")
  data1 <- data1[, ..out.names]
  names(data1)[2] <- paste0(focal.var, "_position")
  
  return(data1)
}

9.3 Updated treegoer.widen() function

What is further needed is that the treegoer.widen() function also includes information on the median:

`treegoer.widen` <- function(
    treegoer,
    species=unique(treegoer$species)[1:100],
    filter.vars=c("bio05", "bio14", "climaticMoistureIndex")
)
{
  
  treegoer.subset <- treegoer$species %in% species
  treegoer <- treegoer[treegoer.subset, ]  
  
  focal.treegoer <- filter.vars[1]
  focal.ranges <- treegoer[treegoer$var == focal.treegoer, 
                           c("species", "n", "MIN", "Q05", "QRT1", "MEDIAN", "QRT3", "Q95", "MAX")]
  names(focal.ranges)[2:9] <- paste0(focal.treegoer, "_", names(focal.ranges)[2:9])
  ranges.lookup <- focal.ranges
  
  for (i in 2:length(filter.vars)) {
    
    focal.treegoer <- filter.vars[i]
    focal.ranges <- treegoer[treegoer$var == focal.treegoer, 
                             c("species", "n", "MIN", "Q05", "QRT1", "MEDIAN", "QRT3", "Q95", "MAX")]
    names(focal.ranges)[2:9] <- paste0(focal.treegoer, "_", names(focal.ranges)[2:9])
    
    # check - note that data was missing for some explanatory variables especially soil 
    cat(paste(focal.treegoer, "- ranges for all species:", all.equal(focal.ranges$species, ranges.lookup$species), "\n"))
    
    ranges.lookup <- dplyr::left_join(ranges.lookup,
                                      focal.ranges,
                                      by="species")
    
#   ranges.lookup <- cbind(ranges.lookup, focal.ranges[, c(2:8)]) # used in the Rpub, can not handle 
  }  
  
  return(ranges.lookup)
  
}

Now we create the new data set, repeating the scripts seen in Section 4 previously:

treegoer.wide <- treegoer.widen(treegoer=treegoer,
                                species=globunt$Switchboard,
                                filter.vars=focal.vars)
## bio12 - ranges for all species: TRUE 
## climaticMoistureIndex - ranges for all species: TRUE 
## monthCountByTemp10 - ranges for all species: TRUE 
## growingDegDays5 - ranges for all species: TRUE 
## bio05 - ranges for all species: TRUE 
## bio06 - ranges for all species: TRUE 
## bio16 - ranges for all species: TRUE 
## bio17 - ranges for all species: TRUE 
## MCWD - ranges for all species: TRUE
names(treegoer.wide)
##  [1] "species"                      "bio01_n"                     
##  [3] "bio01_MIN"                    "bio01_Q05"                   
##  [5] "bio01_QRT1"                   "bio01_MEDIAN"                
##  [7] "bio01_QRT3"                   "bio01_Q95"                   
##  [9] "bio01_MAX"                    "bio12_n"                     
## [11] "bio12_MIN"                    "bio12_Q05"                   
## [13] "bio12_QRT1"                   "bio12_MEDIAN"                
## [15] "bio12_QRT3"                   "bio12_Q95"                   
## [17] "bio12_MAX"                    "climaticMoistureIndex_n"     
## [19] "climaticMoistureIndex_MIN"    "climaticMoistureIndex_Q05"   
## [21] "climaticMoistureIndex_QRT1"   "climaticMoistureIndex_MEDIAN"
## [23] "climaticMoistureIndex_QRT3"   "climaticMoistureIndex_Q95"   
## [25] "climaticMoistureIndex_MAX"    "monthCountByTemp10_n"        
## [27] "monthCountByTemp10_MIN"       "monthCountByTemp10_Q05"      
## [29] "monthCountByTemp10_QRT1"      "monthCountByTemp10_MEDIAN"   
## [31] "monthCountByTemp10_QRT3"      "monthCountByTemp10_Q95"      
## [33] "monthCountByTemp10_MAX"       "growingDegDays5_n"           
## [35] "growingDegDays5_MIN"          "growingDegDays5_Q05"         
## [37] "growingDegDays5_QRT1"         "growingDegDays5_MEDIAN"      
## [39] "growingDegDays5_QRT3"         "growingDegDays5_Q95"         
## [41] "growingDegDays5_MAX"          "bio05_n"                     
## [43] "bio05_MIN"                    "bio05_Q05"                   
## [45] "bio05_QRT1"                   "bio05_MEDIAN"                
## [47] "bio05_QRT3"                   "bio05_Q95"                   
## [49] "bio05_MAX"                    "bio06_n"                     
## [51] "bio06_MIN"                    "bio06_Q05"                   
## [53] "bio06_QRT1"                   "bio06_MEDIAN"                
## [55] "bio06_QRT3"                   "bio06_Q95"                   
## [57] "bio06_MAX"                    "bio16_n"                     
## [59] "bio16_MIN"                    "bio16_Q05"                   
## [61] "bio16_QRT1"                   "bio16_MEDIAN"                
## [63] "bio16_QRT3"                   "bio16_Q95"                   
## [65] "bio16_MAX"                    "bio17_n"                     
## [67] "bio17_MIN"                    "bio17_Q05"                   
## [69] "bio17_QRT1"                   "bio17_MEDIAN"                
## [71] "bio17_QRT3"                   "bio17_Q95"                   
## [73] "bio17_MAX"                    "MCWD_n"                      
## [75] "MCWD_MIN"                     "MCWD_Q05"                    
## [77] "MCWD_QRT1"                    "MCWD_MEDIAN"                 
## [79] "MCWD_QRT3"                    "MCWD_Q95"                    
## [81] "MCWD_MAX"

9.4 Run the analyses

First calculate the climate score again:

treegoer.scores <- treegoer.score(site.species=globunt$Switchboard,
                                  treegoer.wide=treegoer.wide,
                                  filter.vars=PL.vars, 
                                  site.data=site.planting)

Next loop through all the selected variables, calcuting individual scores and positions:

for (i in 1:length(PL.vars)) {
# i <- 1  
  PL.var <- PL.vars[i]
  treegoer.scores2 <- treegoer.score(site.species=globunt$Switchboard,
                                     treegoer.wide=treegoer.wide,
                                     filter.vars=PL.var, 
                                     site.data=site.planting)
  treegoer.scores2 <- treegoer.scores2[, c(1:2)]
  names(treegoer.scores2)[2] <- paste0(PL.var, "_score")
  
  treegoer.scores <- left_join(treegoer.scores,
                               treegoer.scores2,
                               by="species")
  
  treegoer.positions <- treegoer.position(site.data=site.planting,
                                          treegoer.wide=treegoer.wide,
                                          focal.var=PL.var)

  treegoer.scores <- left_join(treegoer.scores,
                               treegoer.positions,
                               by="species")
  
}

What can be seen now are the positions of the planting site for each variable:

summary(treegoer.scores[treegoer.scores$climate.score == 3, ])
##    species          climate.score   n.TreeGOER     bio01_score
##  Length:17          Min.   :3     Min.   : 26.0   Min.   :3   
##  Class :character   1st Qu.:3     1st Qu.: 69.0   1st Qu.:3   
##  Mode  :character   Median :3     Median :132.0   Median :3   
##                     Mean   :3     Mean   :161.1   Mean   :3   
##                     3rd Qu.:3     3rd Qu.:170.0   3rd Qu.:3   
##                     Max.   :3     Max.   :445.0   Max.   :3   
##                                                               
##  bio01_position      bio12_score bio12_position     climaticMoistureIndex_score
##  Min.   :-0.25000   Min.   :3    Min.   :-0.31000   Min.   :3                  
##  1st Qu.:-0.17000   1st Qu.:3    1st Qu.:-0.14000   1st Qu.:3                  
##  Median :-0.09000   Median :3    Median :-0.06000   Median :3                  
##  Mean   :-0.09529   Mean   :3    Mean   :-0.06882   Mean   :3                  
##  3rd Qu.:-0.04000   3rd Qu.:3    3rd Qu.: 0.02000   3rd Qu.:3                  
##  Max.   : 0.17000   Max.   :3    Max.   : 0.12000   Max.   :3                  
##                                                                                
##  climaticMoistureIndex_position monthCountByTemp10_score
##  Min.   :-0.4100                Min.   :3               
##  1st Qu.:-0.2400                1st Qu.:3               
##  Median :-0.1400                Median :3               
##  Mean   :-0.1471                Mean   :3               
##  3rd Qu.: 0.0000                3rd Qu.:3               
##  Max.   : 0.0700                Max.   :3               
##                                                         
##  monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
##  Min.   : NA                 Min.   :3             Min.   :-0.25000        
##  1st Qu.: NA                 1st Qu.:3             1st Qu.:-0.17000        
##  Median : NA                 Median :3             Median :-0.09000        
##  Mean   :NaN                 Mean   :3             Mean   :-0.09471        
##  3rd Qu.: NA                 3rd Qu.:3             3rd Qu.:-0.04000        
##  Max.   : NA                 Max.   :3             Max.   : 0.17000        
##  NA's   :17                                                                
##   bio05_score bio05_position      bio06_score bio06_position      bio16_score
##  Min.   :3    Min.   :-0.20000   Min.   :3    Min.   :-0.24000   Min.   :3   
##  1st Qu.:3    1st Qu.:-0.03000   1st Qu.:3    1st Qu.: 0.04000   1st Qu.:3   
##  Median :3    Median : 0.04000   Median :3    Median : 0.11000   Median :3   
##  Mean   :3    Mean   : 0.04294   Mean   :3    Mean   : 0.07412   Mean   :3   
##  3rd Qu.:3    3rd Qu.: 0.10000   3rd Qu.:3    3rd Qu.: 0.16000   3rd Qu.:3   
##  Max.   :3    Max.   : 0.29000   Max.   :3    Max.   : 0.31000   Max.   :3   
##                                                                              
##  bio16_position      bio17_score bio17_position        MCWD_score
##  Min.   :-0.03000   Min.   :3    Min.   :-0.540000   Min.   :3   
##  1st Qu.: 0.01000   1st Qu.:3    1st Qu.:-0.030000   1st Qu.:3   
##  Median : 0.12000   Median :3    Median : 0.020000   Median :3   
##  Mean   : 0.09235   Mean   :3    Mean   :-0.004118   Mean   :3   
##  3rd Qu.: 0.16000   3rd Qu.:3    3rd Qu.: 0.070000   3rd Qu.:3   
##  Max.   : 0.21000   Max.   :3    Max.   : 0.270000   Max.   :3   
##                                                                  
##  MCWD_position    
##  Min.   :-0.1300  
##  1st Qu.:-0.0100  
##  Median : 0.1900  
##  Mean   : 0.1529  
##  3rd Qu.: 0.2800  
##  Max.   : 0.4100  
## 
head(treegoer.scores[treegoer.scores$climate.score == 3, ])
##                      species climate.score n.TreeGOER bio01_score
## 22            Aloe volkensii             3         30           3
## 24  Anthocleista grandiflora             3        170           3
## 69      Cassipourea malosana             3        138           3
## 112      Croton megalocarpus             3         69           3
## 145       Drypetes gerrardii             3        132           3
## 150  Englerophytum natalense             3         88           3
##     bio01_position bio12_score bio12_position climaticMoistureIndex_score
## 22           -0.25           3           0.00                           3
## 24           -0.17           3          -0.06                           3
## 69           -0.04           3          -0.12                           3
## 112          -0.07           3          -0.21                           3
## 145          -0.18           3          -0.14                           3
## 150          -0.16           3          -0.08                           3
##     climaticMoistureIndex_position monthCountByTemp10_score
## 22                            0.00                        3
## 24                           -0.15                        3
## 69                           -0.29                        3
## 112                          -0.21                        3
## 145                          -0.24                        3
## 150                          -0.31                        3
##     monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
## 22                          NaN                     3                    -0.25
## 24                          NaN                     3                    -0.17
## 69                          NaN                     3                    -0.04
## 112                         NaN                     3                    -0.07
## 145                         NaN                     3                    -0.18
## 150                         NaN                     3                    -0.16
##     bio05_score bio05_position bio06_score bio06_position bio16_score
## 22            3          -0.08           3          -0.24           3
## 24            3          -0.03           3           0.25           3
## 69            3           0.10           3           0.14           3
## 112           3           0.06           3          -0.13           3
## 145           3           0.07           3           0.07           3
## 150           3           0.04           3           0.13           3
##     bio16_position bio17_score bio17_position MCWD_score MCWD_position
## 22            0.16           3          -0.19          3          0.41
## 24            0.07           3           0.10          3          0.19
## 69            0.01           3           0.02          3         -0.01
## 112          -0.01           3          -0.21          3         -0.06
## 145           0.12           3          -0.03          3         -0.04
## 150           0.21           3           0.02          3          0.01
summary(treegoer.scores[treegoer.scores$climate.score == 2, ])
##    species          climate.score   n.TreeGOER        bio01_score   
##  Length:146         Min.   :2     Min.   :    6.00   Min.   :2.000  
##  Class :character   1st Qu.:2     1st Qu.:   83.25   1st Qu.:2.000  
##  Mode  :character   Median :2     Median :  200.50   Median :2.000  
##                     Mean   :2     Mean   :  514.72   Mean   :2.438  
##                     3rd Qu.:2     3rd Qu.:  430.75   3rd Qu.:3.000  
##                     Max.   :2     Max.   :20896.00   Max.   :3.000  
##                                                                     
##  bio01_position     bio12_score    bio12_position    
##  Min.   :-0.8600   Min.   :2.000   Min.   :-0.85000  
##  1st Qu.:-0.4300   1st Qu.:2.000   1st Qu.:-0.25750  
##  Median :-0.2500   Median :3.000   Median :-0.09000  
##  Mean   :-0.2132   Mean   :2.548   Mean   :-0.08068  
##  3rd Qu.: 0.0275   3rd Qu.:3.000   3rd Qu.: 0.14000  
##  Max.   : 0.9200   Max.   :3.000   Max.   : 0.55000  
##                                                      
##  climaticMoistureIndex_score climaticMoistureIndex_position
##  Min.   :2.000               Min.   :-0.8600               
##  1st Qu.:2.000               1st Qu.:-0.3400               
##  Median :3.000               Median :-0.0750               
##  Mean   :2.582               Mean   :-0.1008               
##  3rd Qu.:3.000               3rd Qu.: 0.1175               
##  Max.   :3.000               Max.   : 0.5500               
##                                                            
##  monthCountByTemp10_score monthCountByTemp10_position growingDegDays5_score
##  Min.   :3                Min.   : NA                 Min.   :2.000        
##  1st Qu.:3                1st Qu.: NA                 1st Qu.:2.000        
##  Median :3                Median : NA                 Median :2.000        
##  Mean   :3                Mean   :NaN                 Mean   :2.432        
##  3rd Qu.:3                3rd Qu.: NA                 3rd Qu.:3.000        
##  Max.   :3                Max.   : NA                 Max.   :3.000        
##                           NA's   :146                                      
##  growingDegDays5_position  bio05_score    bio05_position     bio06_score   
##  Min.   :-0.8600          Min.   :2.000   Min.   :-0.8100   Min.   :2.000  
##  1st Qu.:-0.4300          1st Qu.:2.000   1st Qu.:-0.3700   1st Qu.:2.000  
##  Median :-0.2450          Median :3.000   Median :-0.1650   Median :3.000  
##  Mean   :-0.2126          Mean   :2.527   Mean   :-0.1466   Mean   :2.589  
##  3rd Qu.: 0.0350          3rd Qu.:3.000   3rd Qu.: 0.0400   3rd Qu.:3.000  
##  Max.   : 0.9200          Max.   :3.000   Max.   : 0.9200   Max.   :3.000  
##                                                                            
##  bio06_position      bio16_score    bio16_position      bio17_score   
##  Min.   :-0.85000   Min.   :2.000   Min.   :-0.57000   Min.   :2.000  
##  1st Qu.:-0.26000   1st Qu.:2.000   1st Qu.:-0.13750   1st Qu.:2.000  
##  Median :-0.04000   Median :3.000   Median : 0.01500   Median :3.000  
##  Mean   :-0.02336   Mean   :2.719   Mean   : 0.02185   Mean   :2.664  
##  3rd Qu.: 0.22000   3rd Qu.:3.000   3rd Qu.: 0.20750   3rd Qu.:3.000  
##  Max.   : 0.76000   Max.   :3.000   Max.   : 0.78000   Max.   :3.000  
##                                                                       
##  bio17_position       MCWD_score    MCWD_position    
##  Min.   :-0.58000   Min.   :2.000   Min.   :-0.4800  
##  1st Qu.: 0.01250   1st Qu.:2.000   1st Qu.: 0.0400  
##  Median : 0.09000   Median :3.000   Median : 0.3150  
##  Mean   : 0.05699   Mean   :2.541   Mean   : 0.2581  
##  3rd Qu.: 0.18000   3rd Qu.:3.000   3rd Qu.: 0.4500  
##  Max.   : 0.94000   Max.   :3.000   Max.   : 0.8300  
## 
head(treegoer.scores[treegoer.scores$climate.score == 2, ])
##                  species climate.score n.TreeGOER bio01_score bio01_position
## 1     Acalypha fruticosa             2        123           2          -0.41
## 2        Acalypha ornata             2        240           2          -0.37
## 4  Acokanthera schimperi             2         56           3          -0.10
## 16     Albizia gummifera             2        331           3          -0.14
## 26     Antidesma venosum             2        914           2          -0.54
## 29      Avicennia marina             2       1501           3           0.07
##    bio12_score bio12_position climaticMoistureIndex_score
## 1            2           0.30                           2
## 2            3          -0.14                           3
## 4            3           0.14                           2
## 16           2          -0.46                           2
## 26           3          -0.11                           3
## 29           3          -0.19                           2
##    climaticMoistureIndex_position monthCountByTemp10_score
## 1                            0.34                        3
## 2                           -0.07                        3
## 4                            0.18                        3
## 16                          -0.48                        3
## 26                          -0.02                        3
## 29                          -0.37                        3
##    monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
## 1                          NaN                     2                    -0.41
## 2                          NaN                     2                    -0.36
## 4                          NaN                     3                    -0.10
## 16                         NaN                     3                    -0.14
## 26                         NaN                     2                    -0.54
## 29                         NaN                     3                     0.07
##    bio05_score bio05_position bio06_score bio06_position bio16_score
## 1            2          -0.36           3          -0.20           2
## 2            2          -0.24           3          -0.19           3
## 4            3          -0.09           3           0.13           2
## 16           3          -0.02           3          -0.09           2
## 26           2          -0.46           2          -0.33           3
## 29           3          -0.02           3           0.23           3
##    bio16_position bio17_score bio17_position MCWD_score MCWD_position
## 1            0.39           3           0.21          2          0.63
## 2           -0.03           2           0.19          2          0.38
## 4            0.22           3           0.14          2          0.58
## 16          -0.32           3          -0.03          3          0.03
## 26          -0.13           2           0.06          3          0.38
## 29           0.03           3          -0.57          3         -0.13
summary(treegoer.scores[treegoer.scores$climate.score == 1, ])
##    species          climate.score   n.TreeGOER       bio01_score   
##  Length:144         Min.   :1     Min.   :   13.0   Min.   :1.000  
##  Class :character   1st Qu.:1     1st Qu.:  159.8   1st Qu.:1.000  
##  Mode  :character   Median :1     Median :  342.0   Median :1.000  
##                     Mean   :1     Mean   : 1040.3   Mean   :1.382  
##                     3rd Qu.:1     3rd Qu.:  705.8   3rd Qu.:2.000  
##                     Max.   :1     Max.   :39616.0   Max.   :3.000  
##                                                                    
##  bio01_position     bio12_score    bio12_position   
##  Min.   :-1.0000   Min.   :1.000   Min.   :-0.9900  
##  1st Qu.:-0.7700   1st Qu.:2.000   1st Qu.:-0.4325  
##  Median :-0.6100   Median :2.000   Median :-0.0550  
##  Mean   :-0.5751   Mean   :2.097   Mean   :-0.1155  
##  3rd Qu.:-0.4975   3rd Qu.:3.000   3rd Qu.: 0.1950  
##  Max.   : 0.3900   Max.   :3.000   Max.   : 0.8200  
##                                                     
##  climaticMoistureIndex_score climaticMoistureIndex_position
##  Min.   :1.000               Min.   :-0.92000              
##  1st Qu.:2.000               1st Qu.:-0.38750              
##  Median :2.000               Median : 0.05000              
##  Mean   :2.153               Mean   :-0.05583              
##  3rd Qu.:3.000               3rd Qu.: 0.22750              
##  Max.   :3.000               Max.   : 0.93000              
##                                                            
##  monthCountByTemp10_score monthCountByTemp10_position growingDegDays5_score
##  Min.   :2.000            Min.   :1                   Min.   :1.000        
##  1st Qu.:3.000            1st Qu.:1                   1st Qu.:1.000        
##  Median :3.000            Median :1                   Median :1.000        
##  Mean   :2.993            Mean   :1                   Mean   :1.382        
##  3rd Qu.:3.000            3rd Qu.:1                   3rd Qu.:2.000        
##  Max.   :3.000            Max.   :1                   Max.   :3.000        
##                           NA's   :142                                      
##  growingDegDays5_position  bio05_score    bio05_position     bio06_score   
##  Min.   :-0.9900          Min.   :1.000   Min.   :-1.0000   Min.   :1.000  
##  1st Qu.:-0.7700          1st Qu.:1.000   1st Qu.:-0.6600   1st Qu.:2.000  
##  Median :-0.6100          Median :2.000   Median :-0.5250   Median :2.000  
##  Mean   :-0.5747          Mean   :1.667   Mean   :-0.5078   Mean   :2.035  
##  3rd Qu.:-0.4900          3rd Qu.:2.000   3rd Qu.:-0.3900   3rd Qu.:3.000  
##  Max.   : 0.4000          Max.   :3.000   Max.   : 0.3600   Max.   :3.000  
##                                                                            
##  bio06_position     bio16_score    bio16_position     bio17_score   
##  Min.   :-0.9500   Min.   :1.000   Min.   :-0.8700   Min.   :1.000  
##  1st Qu.:-0.5125   1st Qu.:2.000   1st Qu.:-0.3850   1st Qu.:2.000  
##  Median :-0.3400   Median :2.000   Median :-0.1300   Median :2.000  
##  Mean   :-0.2668   Mean   :2.403   Mean   :-0.1102   Mean   :2.174  
##  3rd Qu.:-0.0725   3rd Qu.:3.000   3rd Qu.: 0.1225   3rd Qu.:3.000  
##  Max.   : 0.7600   Max.   :3.000   Max.   : 0.8700   Max.   :3.000  
##                                                                     
##  bio17_position      MCWD_score    MCWD_position    
##  Min.   :-0.7900   Min.   :1.000   Min.   :-0.4800  
##  1st Qu.:-0.0525   1st Qu.:1.000   1st Qu.:-0.0450  
##  Median : 0.1550   Median :2.000   Median : 0.5050  
##  Mean   : 0.1090   Mean   :2.028   Mean   : 0.3582  
##  3rd Qu.: 0.3500   3rd Qu.:3.000   3rd Qu.: 0.6500  
##  Max.   : 0.8000   Max.   :3.000   Max.   : 0.9700  
## 
head(treegoer.scores[treegoer.scores$climate.score == 1, ])
##                     species climate.score n.TreeGOER bio01_score bio01_position
## 3 Acokanthera oppositifolia             1        117           3           0.21
## 5        Adansonia digitata             1       2218           1          -0.60
## 6            Adenium obesum             1        594           1          -0.63
## 7   Afrocanthium lactescens             1         52           2          -0.28
## 8        Afzelia quanzensis             1        252           1          -0.50
## 9         Alangium chinense             1        443           3           0.19
##   bio12_score bio12_position climaticMoistureIndex_score
## 3           2           0.29                           2
## 5           3           0.09                           2
## 6           2           0.14                           2
## 7           3           0.21                           3
## 8           3           0.09                           3
## 9           2          -0.48                           1
##   climaticMoistureIndex_position monthCountByTemp10_score
## 3                           0.21                        3
## 5                           0.19                        3
## 6                           0.26                        3
## 7                           0.20                        3
## 8                           0.14                        3
## 9                          -0.77                        3
##   monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
## 3                         NaN                     3                     0.22
## 5                         NaN                     1                    -0.60
## 6                         NaN                     1                    -0.63
## 7                         NaN                     2                    -0.28
## 8                         NaN                     1                    -0.50
## 9                           1                     3                     0.19
##   bio05_score bio05_position bio06_score bio06_position bio16_score
## 3           3           0.07           1           0.54           2
## 5           1          -0.52           2          -0.32           3
## 6           1          -0.64           3          -0.26           2
## 7           3          -0.06           3          -0.05           3
## 8           1          -0.50           3          -0.08           3
## 9           3          -0.12           2           0.52           2
##   bio16_position bio17_score bio17_position MCWD_score MCWD_position
## 3           0.44           3           0.10          2          0.38
## 5           0.02           1           0.16          2          0.62
## 6           0.09           2           0.15          2          0.65
## 7           0.27           2           0.80          1          0.88
## 8          -0.07           2           0.40          1          0.55
## 9          -0.33           3          -0.25          2         -0.48
summary(treegoer.scores[treegoer.scores$climate.score == 0, ])
##    species          climate.score   n.TreeGOER      bio01_score    
##  Length:138         Min.   :0     Min.   :   1.0   Min.   :0.0000  
##  Class :character   1st Qu.:0     1st Qu.:  22.0   1st Qu.:0.0000  
##  Mode  :character   Median :0     Median :  53.5   Median :0.0000  
##                     Mean   :0     Mean   : 301.1   Mean   :0.3333  
##                     3rd Qu.:0     3rd Qu.: 320.8   3rd Qu.:0.0000  
##                     Max.   :0     Max.   :3499.0   Max.   :3.0000  
##                                                                    
##  bio01_position    bio12_score   bio12_position   climaticMoistureIndex_score
##  Min.   :  -Inf   Min.   :0.00   Min.   :  -Inf   Min.   :0.000              
##  1st Qu.:-1.952   1st Qu.:1.00   1st Qu.:-0.255   1st Qu.:1.000              
##  Median :-1.345   Median :2.00   Median :-0.040   Median :2.000              
##  Mean   :  -Inf   Mean   :1.87   Mean   :  -Inf   Mean   :1.862              
##  3rd Qu.:-1.022   3rd Qu.:3.00   3rd Qu.: 0.700   3rd Qu.:3.000              
##  Max.   : 0.920   Max.   :3.00   Max.   :27.470   Max.   :3.000              
##                                                                              
##  climaticMoistureIndex_position monthCountByTemp10_score
##  Min.   :   -Inf                Min.   :3               
##  1st Qu.:-0.1875                1st Qu.:3               
##  Median : 0.1000                Median :3               
##  Mean   :   -Inf                Mean   :3               
##  3rd Qu.: 0.7700                3rd Qu.:3               
##  Max.   :35.0000                Max.   :3               
##                                                         
##  monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
##  Min.   : NA                 Min.   :0.0000        Min.   :  -Inf          
##  1st Qu.: NA                 1st Qu.:0.0000        1st Qu.:-1.948          
##  Median : NA                 Median :0.0000        Median :-1.345          
##  Mean   :NaN                 Mean   :0.3333        Mean   :  -Inf          
##  3rd Qu.: NA                 3rd Qu.:0.0000        3rd Qu.:-1.020          
##  Max.   : NA                 Max.   :3.0000        Max.   : 0.920          
##  NA's   :138                                                               
##   bio05_score     bio05_position    bio06_score    bio06_position  
##  Min.   :0.0000   Min.   :  -Inf   Min.   :0.000   Min.   :  -Inf  
##  1st Qu.:0.0000   1st Qu.:-1.430   1st Qu.:0.000   1st Qu.:-1.337  
##  Median :0.0000   Median :-1.025   Median :1.000   Median :-0.840  
##  Mean   :0.6739   Mean   :  -Inf   Mean   :1.007   Mean   :  -Inf  
##  3rd Qu.:1.0000   3rd Qu.:-0.775   3rd Qu.:2.000   3rd Qu.:-0.490  
##  Max.   :3.0000   Max.   : 1.240   Max.   :3.000   Max.   : 1.480  
##                                                                    
##   bio16_score    bio16_position     bio17_score    bio17_position   
##  Min.   :0.000   Min.   :   -Inf   Min.   :0.000   Min.   :   -Inf  
##  1st Qu.:2.000   1st Qu.:-0.2175   1st Qu.:1.000   1st Qu.: 0.0125  
##  Median :2.000   Median : 0.0200   Median :2.000   Median : 0.2650  
##  Mean   :2.123   Mean   :   -Inf   Mean   :1.862   Mean   :   -Inf  
##  3rd Qu.:3.000   3rd Qu.: 0.4900   3rd Qu.:3.000   3rd Qu.: 0.5650  
##  Max.   :3.000   Max.   :24.2900   Max.   :3.000   Max.   :33.0000  
##                                                                     
##    MCWD_score    MCWD_position   
##  Min.   :0.000   Min.   :-0.750  
##  1st Qu.:0.000   1st Qu.: 0.310  
##  Median :1.000   Median : 0.750  
##  Mean   :1.261   Mean   :   Inf  
##  3rd Qu.:2.000   3rd Qu.: 1.347  
##  Max.   :3.000   Max.   :   Inf  
## 
head(treegoer.scores[treegoer.scores$climate.score == 0, ])
##                  species climate.score n.TreeGOER bio01_score bio01_position
## 10 Alangium salviifolium             0         48           0          -2.33
## 15    Albizia glaberrima             0        365           0          -1.29
## 19         Albizia zygia             0       1198           0          -1.34
## 25    Antiaris toxicaria             0       1150           0          -1.43
## 28   Asteranthe asterias             0         73           0          -1.51
## 32  Balanites aegyptiaca             0       3499           0          -1.24
##    bio12_score bio12_position climaticMoistureIndex_score
## 10           2          -0.43                           3
## 15           3          -0.15                           3
## 19           2          -0.26                           3
## 25           2          -0.22                           3
## 28           2          -0.45                           2
## 32           2           0.70                           1
##    climaticMoistureIndex_position monthCountByTemp10_score
## 10                          -0.41                        3
## 15                           0.01                        3
## 19                          -0.08                        3
## 25                          -0.08                        3
## 28                          -0.38                        3
## 32                           0.89                        3
##    monthCountByTemp10_position growingDegDays5_score growingDegDays5_position
## 10                         NaN                     0                    -2.36
## 15                         NaN                     0                    -1.28
## 19                         NaN                     0                    -1.34
## 25                         NaN                     0                    -1.43
## 28                         NaN                     0                    -1.50
## 32                         NaN                     0                    -1.23
##    bio05_score bio05_position bio06_score bio06_position bio16_score
## 10           0          -1.33           2          -0.80           2
## 15           0          -1.12           1          -0.86           3
## 19           0          -1.23           1          -0.85           3
## 25           0          -1.08           1          -0.85           3
## 28           0          -1.08           0          -1.44           3
## 32           0          -1.10           1          -0.45           2
##    bio16_position bio17_score bio17_position MCWD_score MCWD_position
## 10          -0.54           3           0.07          2          0.31
## 15           0.05           2           0.17          3         -0.33
## 19          -0.16           2           0.11          3          0.24
## 25          -0.08           2           0.05          3          0.08
## 28          -0.14           3          -0.34          3          0.29
## 32           0.28           0           1.47          1          0.76

9.5 Cross-checking the analyses

Let’s cross-check the calculations for some species

The mean annual temperature for the planting site is:

PL <- as.numeric(site.planting["bio01"])
PL
## [1] 18.93

For this species encountered with overall score of 3, the parameters are:

species.focal <- treegoer.scores[treegoer.scores$climate.score == 3, ][1, "species"]
species.focal
## [1] "Aloe volkensii"
species.median <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MEDIAN"])
species.median
## [1] 20.45
species.minimum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MIN"])
species.minimum
## [1] 14.31
species.maximum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MAX"])
species.maximum
## [1] 26.37

This results in the following calculations:

position.if.above.median <- as.numeric((PL - species.median) / (species.maximum - species.median))
position.if.above.median
## [1] -0.2567568
position.if.below.median <- as.numeric((PL - species.median) / (species.median - species.minimum))
position.if.below.median
## [1] -0.247557
PL >= species.median
## [1] FALSE
species.position <- ifelse(PL >= species.median,
                           position.if.above.median,
                           position.if.below.median)
as.numeric(species.position)
## [1] -0.247557
as.numeric(round(species.position,
                 digits=2))
## [1] -0.25

For another species encountered with overall score of 3, the parameters are:

species.focal <- treegoer.scores[treegoer.scores$climate.score == 3, ][8, "species"]
species.focal
## [1] "Erythrococca fischeri"
species.median <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MEDIAN"])
species.median
## [1] 17.61
species.minimum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MIN"])
species.minimum
## [1] 14.39
species.maximum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MAX"])
species.maximum
## [1] 25.28

This results in the following calculations:

position.if.above.median <- as.numeric((PL - species.median) / (species.maximum - species.median))
position.if.above.median
## [1] 0.1720991
position.if.below.median <- as.numeric((PL - species.median) / (species.median - species.minimum))
position.if.below.median
## [1] 0.4099379
PL >= species.median
## [1] TRUE
species.position <- ifelse(PL >= species.median,
                           position.if.above.median,
                           position.if.below.median)
as.numeric(species.position)
## [1] 0.1720991
as.numeric(round(species.position,
                 digits=2))
## [1] 0.17

For a species encountered with overall score of 0, the parameters are:

species.focal <- treegoer.scores[treegoer.scores$climate.score == 0, ][1, "species"]
species.focal
## [1] "Alangium salviifolium"
species.median <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MEDIAN"])
species.median
## [1] 25.32
species.minimum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MIN"])
species.minimum
## [1] 22.58
species.maximum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MAX"])
species.maximum
## [1] 28.42

This results in the following calculations:

position.if.above.median <- as.numeric((PL - species.median) / (species.maximum - species.median))
position.if.above.median
## [1] -2.06129
position.if.below.median <- as.numeric((PL - species.median) / (species.median - species.minimum))
position.if.below.median
## [1] -2.332117
PL >= species.median
## [1] FALSE
species.position <- ifelse(PL >= species.median,
                           position.if.above.median,
                           position.if.below.median)
as.numeric(species.position)
## [1] -2.332117
as.numeric(round(species.position,
                 digits=2))
## [1] -2.33

For a species encountered with a bio01_score of 1, the parameters are:

species.focal <- treegoer.scores[treegoer.scores$bio01_score == 1, ][1, "species"]
species.focal
## [1] "Adansonia digitata"
species.median <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MEDIAN"])
species.median
## [1] 26.85
species.minimum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MIN"])
species.minimum
## [1] 13.68
species.maximum <- as.numeric(treegoer.wide[treegoer.wide$species == species.focal, "bio01_MAX"])
species.maximum
## [1] 30.53

This results in the following calculations:

position.if.above.median <- as.numeric((PL - species.median) / (species.maximum - species.median))
position.if.above.median
## [1] -2.152174
position.if.below.median <- as.numeric((PL - species.median) / (species.median - species.minimum))
position.if.below.median
## [1] -0.6013667
PL >= species.median
## [1] FALSE
species.position <- ifelse(PL >= species.median,
                           position.if.above.median,
                           position.if.below.median)
as.numeric(species.position)
## [1] -0.6013667
as.numeric(round(species.position,
                 digits=2))
## [1] -0.6

10 Global Biodiversity Standard

This publication was initiated partially from ongoing work in a Darwin Initiative project (DAREX001) that develops a Global Biodiversity Standard for tree planting. The GlobalUsefulNativeTrees database and Tree Globally Observed Environmental Ranges database were realised through co-funding from this project. With scripts such as the ones shown here, when the Global Biodiversity Standard scheme becomes operational, tree planting projects can seek guidance on suitable species for planting.

11 Session Information

sessionInfo()
## R version 4.2.1 (2022-06-23 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United Kingdom.utf8 
## [2] LC_CTYPE=English_United Kingdom.utf8   
## [3] LC_MONETARY=English_United Kingdom.utf8
## [4] LC_NUMERIC=C                           
## [5] LC_TIME=English_United Kingdom.utf8    
## 
## attached base packages:
## [1] tcltk     stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] BiodiversityR_2.16-1 vegan_2.6-4          lattice_0.20-45     
## [4] permute_0.9-7        dplyr_1.1.2          readxl_1.4.1        
## [7] data.table_1.14.2   
## 
## loaded via a namespace (and not attached):
##  [1] nlme_3.1-157        insight_0.18.4      RColorBrewer_1.1-3 
##  [4] tools_4.2.1         backports_1.4.1     bslib_0.4.0        
##  [7] utf8_1.2.2          R6_2.5.1            rpart_4.1.16       
## [10] DBI_1.1.3           Hmisc_4.7-1         nortest_1.0-4      
## [13] mgcv_1.8-40         colorspace_2.0-3    nnet_7.3-17        
## [16] tidyselect_1.2.0    gridExtra_2.3       compiler_4.2.1     
## [19] cli_3.4.1           htmlTable_2.4.1     sandwich_3.0-2     
## [22] tcltk2_1.2-11       effects_4.2-2       sass_0.4.2         
## [25] scales_1.2.1        checkmate_2.1.0     proxy_0.4-27       
## [28] RcmdrMisc_2.9-1     stringr_1.4.1       digest_0.6.29      
## [31] relimp_1.0-5        foreign_0.8-82      minqa_1.2.4        
## [34] rmarkdown_2.16      base64enc_0.1-3     jpeg_0.1-9         
## [37] pkgconfig_2.0.3     htmltools_0.5.6     Rcmdr_2.9-1        
## [40] lme4_1.1-30         fastmap_1.1.1       htmlwidgets_1.5.4  
## [43] rlang_1.1.1         rstudioapi_0.14     jquerylib_0.1.4    
## [46] generics_0.1.3      zoo_1.8-11          jsonlite_1.8.0     
## [49] car_3.1-0           magrittr_2.0.3      Formula_1.2-4      
## [52] interp_1.1-3        Matrix_1.5-1        Rcpp_1.0.11        
## [55] munsell_0.5.0       fansi_1.0.3         abind_1.4-5        
## [58] lifecycle_1.0.3     stringi_1.7.8       yaml_2.3.5         
## [61] carData_3.0-5       MASS_7.3-57         grid_4.2.1         
## [64] parallel_4.2.1      forcats_0.5.2       deldir_1.0-6       
## [67] haven_2.5.1         splines_4.2.1       hms_1.1.2          
## [70] knitr_1.40          pillar_1.9.0        boot_1.3-28        
## [73] glue_1.6.2          evaluate_0.16       mitools_2.4        
## [76] latticeExtra_0.6-30 png_0.1-7           vctrs_0.6.3        
## [79] nloptr_2.0.3        cellranger_1.1.0    gtable_0.3.1       
## [82] cachem_1.0.6        ggplot2_3.4.4       xfun_0.33          
## [85] survey_4.1-1        e1071_1.7-11        class_7.3-20       
## [88] survival_3.3-1      tibble_3.2.1        cluster_2.1.3      
## [91] ellipsis_0.3.2