abundance_byyr()
first picks the main stem of each tree (see
?fgeo.tool::pick_main_stem()
). Then, for each species and each
round-mean-year of measurement, it counts the number of trees. The result
includes main stems within a given dbh range.
basal_area_byyr()
first sums the basal basal area of all stems of each
tree. Then, for each species and each round-mean-year of measurement,
it sums the basal area of all trees. The result includes all stems within a
given dbh range (notice the difference with abundance_byyr()
).
abundance_byyr(vft, ...) basal_area_byyr(vft, ...)
vft | A ForestGEO-like dataframe; particularly a ViewFullTable. As such,
it should contain columns |
---|---|
... | Expressions to pick main stems of a specific |
A dataframe.
You don't need to pick stems by status before feeding data to these
functions. Doing so may make your code more readable but it should not affect
the result. This is because the expressions passed to ...
pick data by
dbh
and exclude the missing dbh
values associated to non-alive stems,
including dead, missing, and gone stems.
Other functions for abundance and basal area:
abundance()
library(fgeo.tool) # Example data vft <- tibble( PlotName = c("luq", "luq", "luq", "luq", "luq", "luq", "luq", "luq"), CensusID = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), TreeID = c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), StemID = c(1.1, 1.2, 2.1, 2.2, 1.1, 1.2, 2.1, 2.2), Status = c( "alive", "dead", "alive", "alive", "alive", "gone", "dead", "dead" ), DBH = c(10L, NA, 20L, 30L, 20L, NA, NA, NA), Genus = c("Gn", "Gn", "Gn", "Gn", "Gn", "Gn", "Gn", "Gn"), SpeciesName = c("spp", "spp", "spp", "spp", "spp", "spp", "spp", "spp"), ExactDate = c( "2001-01-01", "2001-01-01", "2001-01-01", "2001-01-01", "2002-01-01", "2002-01-01", "2002-01-01", "2002-01-01" ), PlotCensusNumber = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), Family = c("f", "f", "f", "f", "f", "f", "f", "f"), Tag = c(1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), HOM = c(130L, 130L, 130L, 130L, 130L, 130L, 130L, 130L) ) vft#> # A tibble: 8 x 13 #> PlotName CensusID TreeID StemID Status DBH Genus SpeciesName ExactDate #> <chr> <int> <int> <dbl> <chr> <int> <chr> <chr> <chr> #> 1 luq 1 1 1.1 alive 10 Gn spp 2001-01-… #> 2 luq 1 1 1.2 dead NA Gn spp 2001-01-… #> 3 luq 1 2 2.1 alive 20 Gn spp 2001-01-… #> 4 luq 1 2 2.2 alive 30 Gn spp 2001-01-… #> 5 luq 2 1 1.1 alive 20 Gn spp 2002-01-… #> 6 luq 2 1 1.2 gone NA Gn spp 2002-01-… #> 7 luq 2 2 2.1 dead NA Gn spp 2002-01-… #> 8 luq 2 2 2.2 dead NA Gn spp 2002-01-… #> # … with 4 more variables: PlotCensusNumber <int>, Family <chr>, Tag <int>, #> # HOM <int>abundance_byyr(vft, DBH >= 10, DBH < 20)#> # A tibble: 1 x 3 #> species family yr_2001 #> <chr> <chr> <dbl> #> 1 Gn spp f 1abundance_byyr(vft, DBH >= 10)#> # A tibble: 1 x 4 #> species family yr_2001 yr_2002 #> <chr> <chr> <dbl> <dbl> #> 1 Gn spp f 2 1basal <- basal_area_byyr(vft, DBH >= 10) basal#> # A tibble: 1 x 4 #> species family yr_2001 yr_2002 #> <chr> <chr> <dbl> <dbl> #> 1 Gn spp f 1100. 314.# Skip R CMD check for speed # \donttest{ measurements_is_installed <- requireNamespace("measurements", quietly = TRUE) if (measurements_is_installed) { # Convert units years <- c("yr_2001", "yr_2002") basal_he <- basal %>% purrr::modify_at( years, ~ measurements::conv_unit(.x, from = "mm2", to = "hectare") ) basal_he # Standardize number_of_hectares <- 50 basal_he %>% purrr::map_at(years, ~ .x / number_of_hectares) }#> $species #> [1] "Gn spp" #> #> $family #> [1] "f" #> #> $yr_2001 #> [1] 2.199115e-09 #> #> $yr_2002 #> [1] 6.283185e-10 #># }