#' @title Plots a barplot of relative AGENTCD dominance
#' @description
#' TODO this
#'
#' @export
PlotPercentAgent <- function(mort_df = NULL) {
# Prep:
ylb <- 'Fraction of plots affected by mortality agent'
if (is.null(mort_df)) {
mort_df <- FIA_mortality_with_explanatory
}
ctbl <- aggregate(mort_df$percent_AGENTCD,
by = list(mort_df$dominant_AGENTCD),
FUN = mean)
colnames(ctbl) <- c('Agent', 'Mean_Perc')
ctbl2 <- aggregate(mort_df$percent_AGENTCD,
by = list(mort_df$dominant_AGENTCD),
FUN = sd)
colnames(ctbl2) <- c('Agent', 'SD_Perc')
ctbl <- dplyr::left_join(ctbl, ctbl2, by = 'Agent')
ctbl <- ctbl[-which(ctbl$Agent == 'No Mortality'), ]
ctbl[, c(2, 3)] <- round(ctbl[, c(2, 3)] / 100, 2)
# Plot:
p0 <- PlotBarPlot(df = ctbl, ylab = ylb)
print(p0)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.