#' Distance to diagonal
#' @description Calculate fraction of coexistence grouping by the distance to diagonal
#' @name dist_to_diag
#' @param adj_matrix adjacent matrix
#' @return ...
# Function for plotting heatwork for a community with given size
dist_to_diag <- function(
adj_matrix) {
m <- adj_matrix
melt_m <- filter(melt(m), Var1 < Var2)
melt_m <- mutate(melt_m, distDiag = Var2 - Var1)
melt_m %>%
group_by(distDiag) %>%
summarize(count = n(), drawCount = sum(value == "draw")) %>%
mutate(fracDraw = drawCount / count)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.