R/simpson_index.R

Defines functions simpson_index

Documented in simpson_index

#' Get alpha diversity using simpson
#'
#' @param x A list of counts
#' @return A single value
#'
#' @examples
#' simpson_index(seq_len(10))
#'
#' @export

simpson_index <- function(x) {
    # Relative abundances
    p <- x/sum(x)

    # Simpson index
    lambda <- sum(p^2)

    lambda
}
hiplot/animalcules documentation built on March 1, 2021, 12:04 a.m.