Phytosociological analysis

For this example we’ll use a database of forestry inventories done in the amazon forest, and make a phytosociological analysis of the area.

library(forestmangr)
data(exfm20)
data_ex <- exfm20

data_ex
#> # A tibble: 12,295 x 18
#>   cod   transect  tree common.name scientific.name family   dbh canopy.pos light
#>   <fct> <fct>    <int> <fct>       <fct>           <fct>  <dbl> <fct>      <int>
#> 1 CAU_~ T01          2 macucu      Licania guiane~ Chrys~  10.3 S              2
#> 2 CAU_~ T01          5 casca seca  Licania canesc~ Chrys~  14.6 S              2
#> 3 CAU_~ T01          6 cajuacu     Anacardium spr~ Anaca~  78.8 E              1
#> 4 CAU_~ T01          7 breu branco Protium panicu~ Burse~  14.7 S              2
#> 5 CAU_~ T01          9 breu branco Protium panicu~ Burse~  10.6 E              3
#> 6 CAU_~ T01         10 caramuxi    Pouteria hispi~ Sapot~  27.1 C              2
#> # ... with 12,289 more rows, and 9 more variables: dead <lgl>, Hcom <dbl>,
#> #   Htot <dbl>, date <int>, utm.east <dbl>, utm.north <dbl>, vol <dbl>,
#> #   plot.area <int>, total.area <int>

First we’ll calculate the diversity indexes of the area, with the species_diversity function. It just needs the data and column name for species:

species_diversity(data_ex, "scientific.name")
#> # A tibble: 1 x 5
#>   Shannon Simpson EqMaxima Pielou Jentsch
#>     <dbl>   <dbl>    <dbl>  <dbl>   <dbl>
#> 1     3.9    0.95     5.15   0.76    0.01

We can evaluate similarity between plots by the Jaccard index, using the similarity_matrix function:

similarity_matrix(data_ex, "scientific.name", "transect", index = "Jaccard")
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,] 1.00 0.38 0.44 0.42 0.36 0.29 0.44 0.39 0.37  0.38  0.39  0.34  0.35
#>  [2,] 0.38 1.00 0.30 0.36 0.30 0.20 0.49 0.34 0.34  0.30  0.37  0.18  0.35
#>  [3,] 0.44 0.30 1.00 0.34 0.33 0.30 0.35 0.36 0.38  0.35  0.37  0.28  0.34
#>  [4,] 0.42 0.36 0.34 1.00 0.29 0.28 0.40 0.36 0.40  0.37  0.35  0.26  0.31
#>  [5,] 0.36 0.30 0.33 0.29 1.00 0.34 0.33 0.44 0.40  0.39  0.32  0.32  0.31
#>  [6,] 0.29 0.20 0.30 0.28 0.34 1.00 0.26 0.44 0.42  0.41  0.33  0.29  0.28
#>  [7,] 0.44 0.49 0.35 0.40 0.33 0.26 1.00 0.36 0.34  0.35  0.34  0.30  0.33
#>  [8,] 0.39 0.34 0.36 0.36 0.44 0.44 0.36 1.00 0.48  0.34  0.37  0.29  0.32
#>  [9,] 0.37 0.34 0.38 0.40 0.40 0.42 0.34 0.48 1.00  0.42  0.43  0.29  0.34
#> [10,] 0.38 0.30 0.35 0.37 0.39 0.41 0.35 0.34 0.42  1.00  0.36  0.26  0.31
#> [11,] 0.39 0.37 0.37 0.35 0.32 0.33 0.34 0.37 0.43  0.36  1.00  0.23  0.33
#> [12,] 0.34 0.18 0.28 0.26 0.32 0.29 0.30 0.29 0.29  0.26  0.23  1.00  0.35
#> [13,] 0.35 0.35 0.34 0.31 0.31 0.28 0.33 0.32 0.34  0.31  0.33  0.35  1.00
#> [14,] 0.32 0.23 0.33 0.31 0.32 0.41 0.24 0.41 0.33  0.32  0.30  0.39  0.35
#> [15,] 0.42 0.31 0.38 0.41 0.35 0.34 0.33 0.36 0.40  0.35  0.42  0.31  0.38
#> [16,] 0.22 0.28 0.31 0.29 0.35 0.34 0.33 0.40 0.30  0.31  0.30  0.26  0.31
#> [17,] 0.24 0.26 0.30 0.22 0.29 0.28 0.28 0.30 0.30  0.29  0.27  0.25  0.28
#> [18,] 0.28 0.25 0.32 0.29 0.29 0.34 0.27 0.36 0.36  0.33  0.25  0.31  0.29
#> [19,] 0.29 0.31 0.26 0.28 0.36 0.29 0.31 0.31 0.33  0.29  0.31  0.29  0.36
#> [20,] 0.26 0.24 0.29 0.29 0.30 0.31 0.23 0.37 0.35  0.26  0.39  0.24  0.38
#> [21,] 0.36 0.33 0.26 0.30 0.31 0.28 0.39 0.38 0.34  0.27  0.42  0.33  0.30
#> [22,] 0.28 0.31 0.27 0.32 0.31 0.32 0.33 0.40 0.38  0.35  0.28  0.29  0.27
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
#>  [1,]  0.32  0.42  0.22  0.24  0.28  0.29  0.26  0.36  0.28
#>  [2,]  0.23  0.31  0.28  0.26  0.25  0.31  0.24  0.33  0.31
#>  [3,]  0.33  0.38  0.31  0.30  0.32  0.26  0.29  0.26  0.27
#>  [4,]  0.31  0.41  0.29  0.22  0.29  0.28  0.29  0.30  0.32
#>  [5,]  0.32  0.35  0.35  0.29  0.29  0.36  0.30  0.31  0.31
#>  [6,]  0.41  0.34  0.34  0.28  0.34  0.29  0.31  0.28  0.32
#>  [7,]  0.24  0.33  0.33  0.28  0.27  0.31  0.23  0.39  0.33
#>  [8,]  0.41  0.36  0.40  0.30  0.36  0.31  0.37  0.38  0.40
#>  [9,]  0.33  0.40  0.30  0.30  0.36  0.33  0.35  0.34  0.38
#> [10,]  0.32  0.35  0.31  0.29  0.33  0.29  0.26  0.27  0.35
#> [11,]  0.30  0.42  0.30  0.27  0.25  0.31  0.39  0.42  0.28
#> [12,]  0.39  0.31  0.26  0.25  0.31  0.29  0.24  0.33  0.29
#> [13,]  0.35  0.38  0.31  0.28  0.29  0.36  0.38  0.30  0.27
#> [14,]  1.00  0.40  0.39  0.27  0.37  0.37  0.41  0.40  0.35
#> [15,]  0.40  1.00  0.32  0.32  0.36  0.34  0.40  0.37  0.27
#> [16,]  0.39  0.32  1.00  0.38  0.27  0.28  0.40  0.30  0.36
#> [17,]  0.27  0.32  0.38  1.00  0.30  0.26  0.31  0.26  0.28
#> [18,]  0.37  0.36  0.27  0.30  1.00  0.32  0.33  0.30  0.36
#> [19,]  0.37  0.34  0.28  0.26  0.32  1.00  0.35  0.41  0.34
#> [20,]  0.41  0.40  0.40  0.31  0.33  0.35  1.00  0.33  0.33
#> [21,]  0.40  0.37  0.30  0.26  0.30  0.41  0.33  1.00  0.28
#> [22,]  0.35  0.27  0.36  0.28  0.36  0.34  0.33  0.28  1.00

We can also generate a dendrogram for this analysis:

similarity_matrix(exfm20, "scientific.name", "transect", index = "Jaccard", dendrogram = TRUE, n_groups = 3)
#> $Dendrogram
#> $Dendrogram[[1]]

#> 
#> 
#> $Matrix
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
#>  [1,] 1.00 0.38 0.44 0.42 0.36 0.29 0.44 0.39 0.37  0.38  0.39  0.34  0.35
#>  [2,] 0.38 1.00 0.30 0.36 0.30 0.20 0.49 0.34 0.34  0.30  0.37  0.18  0.35
#>  [3,] 0.44 0.30 1.00 0.34 0.33 0.30 0.35 0.36 0.38  0.35  0.37  0.28  0.34
#>  [4,] 0.42 0.36 0.34 1.00 0.29 0.28 0.40 0.36 0.40  0.37  0.35  0.26  0.31
#>  [5,] 0.36 0.30 0.33 0.29 1.00 0.34 0.33 0.44 0.40  0.39  0.32  0.32  0.31
#>  [6,] 0.29 0.20 0.30 0.28 0.34 1.00 0.26 0.44 0.42  0.41  0.33  0.29  0.28
#>  [7,] 0.44 0.49 0.35 0.40 0.33 0.26 1.00 0.36 0.34  0.35  0.34  0.30  0.33
#>  [8,] 0.39 0.34 0.36 0.36 0.44 0.44 0.36 1.00 0.48  0.34  0.37  0.29  0.32
#>  [9,] 0.37 0.34 0.38 0.40 0.40 0.42 0.34 0.48 1.00  0.42  0.43  0.29  0.34
#> [10,] 0.38 0.30 0.35 0.37 0.39 0.41 0.35 0.34 0.42  1.00  0.36  0.26  0.31
#> [11,] 0.39 0.37 0.37 0.35 0.32 0.33 0.34 0.37 0.43  0.36  1.00  0.23  0.33
#> [12,] 0.34 0.18 0.28 0.26 0.32 0.29 0.30 0.29 0.29  0.26  0.23  1.00  0.35
#> [13,] 0.35 0.35 0.34 0.31 0.31 0.28 0.33 0.32 0.34  0.31  0.33  0.35  1.00
#> [14,] 0.32 0.23 0.33 0.31 0.32 0.41 0.24 0.41 0.33  0.32  0.30  0.39  0.35
#> [15,] 0.42 0.31 0.38 0.41 0.35 0.34 0.33 0.36 0.40  0.35  0.42  0.31  0.38
#> [16,] 0.22 0.28 0.31 0.29 0.35 0.34 0.33 0.40 0.30  0.31  0.30  0.26  0.31
#> [17,] 0.24 0.26 0.30 0.22 0.29 0.28 0.28 0.30 0.30  0.29  0.27  0.25  0.28
#> [18,] 0.28 0.25 0.32 0.29 0.29 0.34 0.27 0.36 0.36  0.33  0.25  0.31  0.29
#> [19,] 0.29 0.31 0.26 0.28 0.36 0.29 0.31 0.31 0.33  0.29  0.31  0.29  0.36
#> [20,] 0.26 0.24 0.29 0.29 0.30 0.31 0.23 0.37 0.35  0.26  0.39  0.24  0.38
#> [21,] 0.36 0.33 0.26 0.30 0.31 0.28 0.39 0.38 0.34  0.27  0.42  0.33  0.30
#> [22,] 0.28 0.31 0.27 0.32 0.31 0.32 0.33 0.40 0.38  0.35  0.28  0.29  0.27
#>       [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22]
#>  [1,]  0.32  0.42  0.22  0.24  0.28  0.29  0.26  0.36  0.28
#>  [2,]  0.23  0.31  0.28  0.26  0.25  0.31  0.24  0.33  0.31
#>  [3,]  0.33  0.38  0.31  0.30  0.32  0.26  0.29  0.26  0.27
#>  [4,]  0.31  0.41  0.29  0.22  0.29  0.28  0.29  0.30  0.32
#>  [5,]  0.32  0.35  0.35  0.29  0.29  0.36  0.30  0.31  0.31
#>  [6,]  0.41  0.34  0.34  0.28  0.34  0.29  0.31  0.28  0.32
#>  [7,]  0.24  0.33  0.33  0.28  0.27  0.31  0.23  0.39  0.33
#>  [8,]  0.41  0.36  0.40  0.30  0.36  0.31  0.37  0.38  0.40
#>  [9,]  0.33  0.40  0.30  0.30  0.36  0.33  0.35  0.34  0.38
#> [10,]  0.32  0.35  0.31  0.29  0.33  0.29  0.26  0.27  0.35
#> [11,]  0.30  0.42  0.30  0.27  0.25  0.31  0.39  0.42  0.28
#> [12,]  0.39  0.31  0.26  0.25  0.31  0.29  0.24  0.33  0.29
#> [13,]  0.35  0.38  0.31  0.28  0.29  0.36  0.38  0.30  0.27
#> [14,]  1.00  0.40  0.39  0.27  0.37  0.37  0.41  0.40  0.35
#> [15,]  0.40  1.00  0.32  0.32  0.36  0.34  0.40  0.37  0.27
#> [16,]  0.39  0.32  1.00  0.38  0.27  0.28  0.40  0.30  0.36
#> [17,]  0.27  0.32  0.38  1.00  0.30  0.26  0.31  0.26  0.28
#> [18,]  0.37  0.36  0.27  0.30  1.00  0.32  0.33  0.30  0.36
#> [19,]  0.37  0.34  0.28  0.26  0.32  1.00  0.35  0.41  0.34
#> [20,]  0.41  0.40  0.40  0.31  0.33  0.35  1.00  0.33  0.33
#> [21,]  0.40  0.37  0.30  0.26  0.30  0.41  0.33  1.00  0.28
#> [22,]  0.35  0.27  0.36  0.28  0.36  0.34  0.33  0.28  1.00

To evaluate the level of aggregation among species in the area, we can use the species_aggreg function:

species_aggreg(data_ex, "scientific.name", "transect")
#> # A tibble: 172 x 7
#>   especie             Payandeh Pay.res    Hazen Haz.res       Morisita Mor.res  
#>   <fct>                  <dbl> <chr>      <dbl> <chr>            <dbl> <chr>    
#> 1 Abarema cochleata        0.9 Regular      18  Not aggregat~      0   Rare     
#> 2 Abarema jupunba          0.9 Regular      19  Not aggregat~      0   Rare     
#> 3 Abuta grandifolia       16   Aggregated  337. Aggregated        11.9 Aggregat~
#> 4 Aiouea sp.               9.5 Aggregated  200  Aggregated        10.4 Aggregat~
#> 5 Ambelania acida         10   Aggregated  210  Aggregated        22   Aggregat~
#> 6 Anacardium sprucea~      9.3 Aggregated  195. Aggregated         7.7 Aggregat~
#> # ... with 166 more rows

We can also evaluate the horizontal structure of the forest. To do this, we can use the forest_structure function:

forest_structure(data_ex, "scientific.name", "dbh", "transect", 10000)
#> # A tibble: 172 x 9
#>   especie                  AF     RF    AD     DR     ADo    RDo    IVC    IVI
#>   <fct>                 <dbl>  <dbl> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>  <dbl>
#> 1 Abarema cochleata     18.2  0.392  0.182 0.0343 0.0359  0.137  0.0859 0.188 
#> 2 Abarema jupunba       13.6  0.294  0.136 0.0258 0.0302  0.116  0.0707 0.145 
#> 3 Abuta grandifolia      9.09 0.196  1.36  0.258  0.0162  0.0621 0.160  0.172 
#> 4 Aiouea sp.             9.09 0.196  0.909 0.172  0.0413  0.158  0.165  0.175 
#> 5 Ambelania acida        4.55 0.0979 0.454 0.0859 0.00379 0.0145 0.0502 0.0661
#> 6 Anacardium spruceanum 27.3  0.588  1.23  0.232  0.159   0.608  0.420  0.476 
#> # ... with 166 more rows

It’s also possible to calculate the vertical and internal structures:

forest_structure(data_ex, "scientific.name", "dbh", "transect", 10000, "canopy.pos", "light") 
#> # A tibble: 172 x 19
#>   especie    AF     RF    AD     DR     ADo    RDo    IVC    IVI   VFC   VFE
#>   <fct>   <dbl>  <dbl> <dbl>  <dbl>   <dbl>  <dbl>  <dbl>  <dbl> <dbl> <dbl>
#> 1 Abarem~ 18.2  0.392  0.182 0.0343 0.0359  0.137  0.0859 0.188   51.2   0  
#> 2 Abarem~ 13.6  0.294  0.136 0.0258 0.0302  0.116  0.0707 0.145   25.6   0  
#> 3 Abuta ~  9.09 0.196  1.36  0.258  0.0162  0.0621 0.160  0.172    0     0  
#> 4 Aiouea~  9.09 0.196  0.909 0.172  0.0413  0.158  0.165  0.175    0     0  
#> 5 Ambela~  4.55 0.0979 0.454 0.0859 0.00379 0.0145 0.0502 0.0661   0     0  
#> 6 Anacar~ 27.3  0.588  1.23  0.232  0.159   0.608  0.420  0.476   38.4  13.4
#> # ... with 166 more rows, and 8 more variables: VFS <dbl>, PSA <dbl>,
#> #   PSR <dbl>, QF1 <dbl>, QF2 <dbl>, QF3 <dbl>, QAF <dbl>, QRF <dbl>

To check if the forest is regulated, we can use the BDq method, with the bdq_meyer function:

bdq_meyer(data_ex, "transect", "dbh", 1000,licourt_index = 2)
#>    Class_Center NumIndv IndvHectare Meyer   q MeyerBalan
#> 1          12.5    4730      2150.0   564 1.8       5101
#> 2          17.5    2700      1227.3   434 1.5       2550
#> 3          22.5    1840       836.4   335 2.0       1275
#> 4          27.5     930       422.7   258 1.4        638
#> 5          32.5     670       304.5   199 1.8        319
#> 6          37.5     369       167.7   153 1.3        159
#> 7          42.5     291       132.3   118 1.4         80
#> 8          47.5     208        94.5    91 1.2         40
#> 9          52.5     180        81.8    70 1.6         20
#> 10         57.5     116        52.7    54 1.9         10
#> 11         62.5      60        27.3    42 1.2          5
#> 12         67.5      49        22.3    32 1.2          2
#> 13         72.5      40        18.2    25 1.9          1
#> 14         77.5      21         9.5    19 0.7          1
#> 15         82.5      29        13.2    15 1.5          0
#> 16         87.5      20         9.1    11 1.5          0
#> 17         92.5      13         5.9     9 1.6          0
#> 18         97.5       8         3.6     7 2.6          0
#> 19        102.5       3         1.4     5 0.8          0
#> 20        107.5       4         1.8     4 1.3          0
#> 21        112.5       3         1.4     3 2.8          0
#> 22        117.5       1         0.5     2 0.4          0
#> 23        122.5       3         1.4     2 2.8          0
#> 24        127.5       1         0.5     1 1.0          0
#> 25        142.5       1         0.5     1 1.0          0
#> 26        147.5       1         0.5     0 0.6          0
#> 27        152.5       2         0.9     0 1.8          0
#> 28        162.5       1         0.5     0 1.0          0
#> 29        202.5       1         0.5     0  NA          0

With the diameter_class function it’s possible to divide the data in diameter classes, and get the number of individuals per species in each class:

classified <- diameter_class(data_ex,"dbh", "transect", 10000, 10, 10, "scientific.name") 
#> Warning: Unquoting language objects with `!!!` is deprecated as of rlang 0.4.0.
#> Please use `!!` instead.
#> 
#>   # Bad:
#>   dplyr::select(data, !!!enquo(x))
#> 
#>   # Good:
#>   dplyr::select(data, !!enquo(x))    # Unquote single quosure
#>   dplyr::select(data, !!!enquos(x))  # Splice list of quosures
#> 
#> This warning is displayed once per session.

head(classified)
#>         scientific.name CC NumIndv IndvHA          G        G_ha       RD
#> 1     Abuta grandifolia 15      30    1.4 0.35676712 0.016216687 100.0000
#> 2            Aiouea sp. 15      10    0.5 0.09331316 0.004241507  50.0000
#> 3       Ambelania acida 15      10    0.5 0.08332289 0.003787404 100.0000
#> 4 Anacardium spruceanum 15      10    0.5 0.27171635 0.012350743  37.0370
#> 5       Aniba canelilla 15      10    0.5 0.08332289 0.003787404  90.9091
#> 6      Aniba parviflora 15      10    0.5 0.10568318 0.004803781 100.0000

Another way of visualizing this table is to spread the center of class to columns. We can do this with the cc_to_column argument:

classified <- diameter_class(data_ex,"dbh", "transect", 10000, 10, 10,
               "scientific.name", cc_to_column=TRUE)
head(classified)
#>         scientific.name  15  25  35  45  55  65  75 85 95 105 115 125 145 155
#> 1     Abarema cochleata             0.1 0.1                                  
#> 2       Abarema jupunba                 0.1                                  
#> 3     Abuta grandifolia 1.4                                                  
#> 4            Aiouea sp. 0.5     0.5                                          
#> 5       Ambelania acida 0.5                                                  
#> 6 Anacardium spruceanum 0.5 0.5             0.1 0.1                          
#>   165 205 Total
#> 1           0.2
#> 2           0.1
#> 3           1.4
#> 4             1
#> 5           0.5
#> 6           1.2