R/fSimpson.R

Defines functions fSimpson

Documented in fSimpson

fSimpson <-
function(x, k, n, location){
  nx <- length(x)
  if (nx==0) stop("No observations)")
  if (k=="") stop("k is missing)")
  if (n=="") stop("n is missing)")
  if (location=="") stop("location is missing)")

  h <- aggregate((x[[k]] / x[[n]])^2, by=list(Category=x[[location]]), FUN=sum)
  h <- data.frame(h, 1-h[2])
  names(h) <- c("location", "simpson", "divSimpson")
  return(h)
}

Try the OnomasticDiversity package in your browser

Any scripts or data that you put into this service are public.

OnomasticDiversity documentation built on May 29, 2024, 1:32 a.m.