## calculate G for inventory data grouped by plot_id and species
library(dplyr)
inventory_samples |>
mutate(dclass = silv_diametric_class(diameter)) |>
summarise(
height = mean(height, na.rm = TRUE),
ntrees = n(),
.by = c(plot_id, species, dclass)
) |>
mutate(
ntrees_ha = silv_ntrees_ha(ntrees, plot_size = 10),
dg = silv_sqrmean_diameter(dclass, ntrees_ha),
g = silv_basal_area(dclass, ntrees_ha),
.by = c(plot_id, species)
)
## calculate individual basal area
silv_basal_area(c(23, 11, 43.5, 94))
Run the code above in your browser using DataLab