#' Calculate mean beta diversity
#' @description Mean beta diversity
#' @name beta_diversity
#' @param x community matrix whose columns represent species and rows indicate sites
#' @return ...
beta_diversity <- function(x, method = "bray") {
x_dist <- x %>%
select(-function_group) %>%
group_by(treatment, replicate) %>%
spread(variable, value, fill = 0) %>%
`[`(., -c(1, 2)) %>%
as.matrix() %>%
vegdist(method = method)
<<<<<<< HEAD
return(list(
mean = mean(x_dist),
sd = sd(x_dist)
))
}
=======
return(data.frame(mean = mean(x_dist),
sd = sd(x_dist)))
}
>>>>>>> 381875eedd7472bfbaf2cfd62d780ca03ff9b601
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.