R/specnumber.R

`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 May 2, 2019, 5:51 p.m.