Nothing
calc_simpson <- function(data, index='simpson') {
# Ensure the input is a numeric vector or matrix
if (!is.numeric(data)) {
stop("Input data must be a numeric vector or matrix.")
}
# Calculate the p for each item
total = sum(data)
p = data/total
H = sum(p^2, na.rm = TRUE)
if (index == "simpson"){
H = 1 - H
} else if (index == "invsimpson") {
H = 1/H
}
return(H)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.