fgeo helps you to install, load, and access the documentation of multiple packages to analyze forest diversity and dynamics (fgeo.analyze, fgeo.plot, fgeo.tool, fgeo.x). This package-collection allows you to manipulate and plot ForestGEO data, and to do common analyses including abundance, demography, and species-habitats associations.

Installation

Make sure your R environment is as follows:

  • R version is recent
  • All packages are updated (run update.packages(); maybe use ask = FALSE)
  • No other R session is running
  • Current R session is clean (click Session > Restart R)

Example

Explore fgeo

On an interactive session, fgeo_help() and fgeo_browse_reference() help you to search documentation.

if (interactive()) {
  # To search on the viewer; accepts keywords
  fgeo_help()
  # To search on a web browser
  fgeo_browse_reference() 
}

Access and manipulate data

example_path() allows you to access datasets stored in your R libraries.

pick_<what>() and drop_<what>()

fgeo is pipe-friendly. You may not use pipes but often they make code easier to read.

Use %>% to emphasise a sequence of actions, rather than the object that the actions are being performed on.

https://style.tidyverse.org/pipes.html

pick_dbh_under(), drop_status() and friends pick and drop rows from a ForestGEO ViewFullTable or census table.

(census <- fgeo.x::tree5)
#> # A tibble: 30 x 19
#>    treeID stemID tag   StemTag sp    quadrat    gx    gy MeasureID CensusID
#>     <int>  <int> <chr> <chr>   <chr> <chr>   <dbl> <dbl>     <int>    <int>
#>  1   7624 160987 1089… 175325  TRIP… 722     139.  425.     486675        5
#>  2   8055  10036 1094… 109482  CECS… 522      94.8 424.     468874        5
#>  3  19930 117849 1234… 165576  CASA… 425      61.3 496.     471979        5
#>  4  23746  29677 14473 14473   PREM… 617     100.  328.     442571        5
#>  5  31702  39793 22889 22889   SLOB… 304      53.8  73.8    447307        5
#>  6  35355  44026 27538 27538   SLOB… 1106    203.  110.     449169        5
#>  7  35891  44634 282   282     DACE… 901     172.   14.7    434266        5
#>  8  39705  48888 33371 33370   CASS… 1010    184.  194.     451067        5
#>  9  50184  60798 5830  5830    MATD… 1007    191.  132.     437645        5
#> 10  57380 155867 66962 171649  SLOB… 1414    274.  279.     459427        5
#> # … with 20 more rows, and 9 more variables: dbh <dbl>, pom <chr>,
#> #   hom <dbl>, ExactDate <date>, DFstatus <chr>, codes <chr>,
#> #   nostems <dbl>, status <chr>, date <dbl>

census %>% 
  pick_dbh_under(100)
#> # A tibble: 18 x 19
#>    treeID stemID tag   StemTag sp    quadrat    gx    gy MeasureID CensusID
#>     <int>  <int> <chr> <chr>   <chr> <chr>   <dbl> <dbl>     <int>    <int>
#>  1   7624 160987 1089… 175325  TRIP… 722     139.  425.     486675        5
#>  2  19930 117849 1234… 165576  CASA… 425      61.3 496.     471979        5
#>  3  31702  39793 22889 22889   SLOB… 304      53.8  73.8    447307        5
#>  4  35355  44026 27538 27538   SLOB… 1106    203.  110.     449169        5
#>  5  39705  48888 33371 33370   CASS… 1010    184.  194.     451067        5
#>  6  57380 155867 66962 171649  SLOB… 1414    274.  279.     459427        5
#>  7  95656 129113 1315… 131519  OCOL… 402      79.7  22.8    474157        5
#>  8  96051 129565 1323… 132348  HIRR… 1403    278    40.6    474523        5
#>  9  96963 130553 1347… 134707  TETB… 610     114.  182.     475236        5
#> 10 115310 150789 1652… 165286  MANB… 225      24.0 497.     483175        5
#> 11 121424 158579 1707… 170701  CASS… 811     146.  218.     484785        5
#> 12 121689 158871 1712… 171277  INGL… 515      84.2 285.     485077        5
#> 13 121953 159139 1718… 171809  PSYB… 1318    247.  354.     485345        5
#> 14 124522 162698 1742… 174224  CASS… 1411    279.  210.     488386        5
#> 15 125038 163236 1753… 175335  CASS… 822     153.  426.     488924        5
#> 16 126087     NA 1773… <NA>    CASA… 521      89.8 408.         NA       NA
#> 17 126803     NA 1785… <NA>    PSYB… 622     113.  426          NA       NA
#> 18 126934     NA 1787… <NA>    MICR… 324      47   480.         NA       NA
#> # … with 9 more variables: dbh <dbl>, pom <chr>, hom <dbl>,
#> #   ExactDate <date>, DFstatus <chr>, codes <chr>, nostems <dbl>,
#> #   status <chr>, date <dbl>

pick_main_stem() and pick_main_stemid() pick the main stem or main stemid(s) of each tree in each census.

Plot data

For simplicity, we will focus on only a few species.

stem_2sp <- stem %>% 
  filter(sp %in% c("PREMON", "CASARB"))

autoplot() and friends produce different output depending on the class of input. You can create different input classes, for example, with sp() and sp_elev():

  • Use sp(census) to plot the column sp of a census dataset – i.e. to plot species distribution.

  • Use sp_elev(census, elevation) to plot the columns sp and elev of a census and elevation dataset, respectively – i.e. to plot species distribution and topography.

Analyze

R code from recent publications by ForestGEO partners

Data have been made available as required by the journal to enable reproduction of the results presented in the paper. Please do not share these data without permission of the ForestGEO plot Principal Investigators (PIs). If you wish to publish papers based on these data, you are also required to get permission from the PIs of the corresponding ForestGEO plots.

Acknowledgments

Thanks to all partners of ForestGEO for sharing their ideas and code. For feedback on fgeo, special thanks to Gabriel Arellano, Stuart Davies, Lauren Krizel, Sean McMahon, and Haley Overstreet. For all other help, I thank contributors in the the documentation of the features they helped with.