R/specnumber.R

Defines functions `specnumber`

`specnumber` <-
    function(x, groups, MARGIN = 1)
{
    if (!missing(groups)) {
        if (length(groups) == 1)
            groups <- rep(groups, nrow(x))
        x <- aggregate(x, list(groups), max)
        rownames(x) <- x[,1]
        x <- x[,-1]
    }
    if (length(dim(x)) > 1)
        apply(x > 0, MARGIN, sum)
    else
        sum(x > 0)
}

Try the vegan package in your browser

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

vegan documentation built on Oct. 11, 2022, 5:06 p.m.