R/fSimpsonInf.R

Defines functions fSimpsonInf

Documented in fSimpsonInf

fSimpsonInf <-
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[[k]] -1) / (x[[n]]*(x[[n]] -1)) ), by=list(Category=x[[location]]), FUN=sum)
  names(h) <- c("location", "simpson")
  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.