## calculate d0 for inventory data grouped by plot_id and species
library(dplyr)
inventory_samples |>
mutate(dclass = silv_tree_dclass(diameter)) |>
summarise(
height = mean(height, na.rm = TRUE),
ntrees = n(),
.by = c(plot_id, species, dclass)
) |>
mutate(
ntrees_ha = silv_density_ntrees_ha(ntrees, plot_size = 10),
d0 = silv_stand_dominant_diameter(dclass, ntrees_ha),
.by = c(plot_id, species)
)
Run the code above in your browser using DataLab