R/spenvcor.R

`spenvcor` <-
    function (object)
{
    if (is.null(object$CCA))
        stop("needs results from constrained ordination")
    u <- object$CCA$u
    wa <- object$CCA$wa
    if (!inherits(object, "rda")) { # is CCA
        r <- sqrt(object$rowsum)
        u <- r * u
        wa <- r * wa
    }
    ## because colSums(u*u) = 1, we can simplify diag(cor(u, wa)) --
    ## and we must for weighted CA
    colSums(u * wa)/sqrt(colSums(wa^2))
}

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.