#' A function for calculating mean basal area and stem density across all
#' study sites.
#'
#' @import tidyr dplyr
#' @return ForestStructSumm A tibble containing forest structure summary statistics.
#'
ForestStructure <- function(){
ForestStruct <- NonSeedlingData %>%
mutate(BA = BAFormula(.)) %>%
group_by(Site, Transect, PlotCode) %>%
summarise(BA = sum(BA)) %>%
full_join(NonSeedlingData %>%
count(Site, Transect, PlotCode),
by = c("Site", "Transect", "PlotCode")) %>%
right_join(PlotData) %>%
replace_na(list(BA = 0,
n = 0))
PlotSize <- pi * 4 * 4
ForestStructSumm <- ForestStruct %>%
mutate(BAPerHect = BA * (10000 / PlotSize),
TreesPerHect = n * (10000 / PlotSize)) %>%
ungroup() %>%
summarise(MeanBA = mean(BAPerHect),
SDBA = sd(BAPerHect),
MeanTrees = mean(TreesPerHect),
SDTrees = sd(TreesPerHect))
return(ForestStructSumm)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.