R/vegtab.R

Defines functions vegtab

Documented in vegtab

vegtab <- function(comm,set,minval=1,pltord,spcord,pltlbl,trans=FALSE)
{
    if (missing(set)) {
        set <- seq(1:nrow(comm))
    } else {
        set <- seq(1:nrow(comm))[set]
        set <- set[!is.na(set)]
    }
    tmp <- comm[set,]
    spcidx <- apply(tmp>0,2,sum)
    tmp <- tmp[,spcidx >= minval]

    if (missing(pltord)) {
        pltord <- seq(1:nrow(tmp))
    } else {
        pltord <- pltord[set]
    }
    if (missing(spcord)) {
        x <- apply(tmp > 0, 2, sum)
        y <- apply(tmp, 2, sum)
        spcord <- -1 * (x + y/max(y))
        #spcord <- -apply(tmp > 0, 2, sum)
    } else {
        spcord <- spcord[spcidx >= minval]
    }
    if (!missing(pltlbl)) {
        if (is.numeric(pltlbl)) {
            tmp <- cbind(pltlbl[set],tmp)
            dimnames(tmp)[[2]][1] <- deparse(substitute(pltlbl))
            spcord <- c(min(spcord)-1,spcord)
        } else {
            dimnames(tmp)[[1]] <- pltlbl
        }
    }
    tmp <- tmp[order(pltord),order(spcord)]
    if (trans==TRUE) {
        tmp <- t(tmp)
    }
    tmp
}

Try the labdsv package in your browser

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

labdsv documentation built on April 10, 2023, 5:08 p.m.