R/rda.formula.R

`rda.formula` <-
    function (formula, data, scale = FALSE, na.action = na.fail,
              subset = NULL, ...) 
{
    if (missing(data)) {
        data <- parent.frame()
    } else {
        data <- ordiGetData(match.call(), environment(formula))
    }
    d <- ordiParseFormula(formula, data, na.action = na.action,
                          subset = substitute(subset))
    sol <- rda.default(d$X, d$Y, d$Z, scale)
    if (!is.null(sol$CCA) && sol$CCA$rank > 0) 
        sol$CCA$centroids <- centroids.cca(sol$CCA$wa, d$modelframe)
    if (!is.null(sol$CCA$alias)) 
        sol$CCA$centroids <- unique(sol$CCA$centroids)
    if (!is.null(sol$CCA$centroids)) {
        rs <- rowSums(sol$CCA$centroids^2)
        sol$CCA$centroids <- sol$CCA$centroids[rs > 1e-04, , 
            drop = FALSE]
        if (length(sol$CCA$centroids) == 0)
            sol$CCA$centroids <- NULL
    }
    sol$terms <- d$terms
    sol$terminfo <- ordiTerminfo(d, d$modelframe)
    sol$subset <- d$subset
    sol$na.action <- d$na.action
    sol$call <- match.call()
    sol$call[[1]] <- as.name("rda")
    sol$call$formula <- formula(d$terms, width.cutoff = 500)
    if (!is.null(sol$na.action))
        sol <- ordiNAexclude(sol, d$excluded)
    sol
}

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.