File: ordixyplot.R

package info (click to toggle)
r-cran-vegan 2.5-7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,564 kB
  • sloc: ansic: 2,275; fortran: 1,088; sh: 42; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
`ordixyplot` <-
    function(x, data = NULL, formula, display = "sites", choices=1:3,
             panel = "panel.ordi", aspect = "iso", envfit,
             type = c("p", "biplot"),  ...)
{
    localXyplot <- function(..., shrink, origin, scaling) xyplot(...)
    p <- as.data.frame(scores(x, display = display, choices = choices, ...))
    if (!is.null(data))
        p <- cbind(p, data)
    if (missing(formula)) {
        v <- colnames(p)
        formula <- as.formula(paste(v[2], "~", v[1]))
    }
    if ("biplot" %in% type && ((!is.null(x$CCA) && x$CCA$rank > 0) ||
                                   !missing(envfit))) {
        if (missing(envfit))
            envfit <- NULL
        env <- ordilattice.getEnvfit(formula, x, envfit, choices, ...)
        if (!is.null(env$arrows)) {
            mul <- apply(p[,colnames(env$arrows)], 2, range)/apply(env$arrows, 2, range)
            mul <- min(mul[is.finite(mul) & mul > 0])
            env$arrows <- mul * env$arrows
        }
    } else {
        env <- NULL
    }
    ## plot polygon for all data plus superpose polygons for each panel
    if ("polygon" %in% type) {
        pol <- p[, all.vars(formula)[2:1]]
        pol <- pol[chull(pol),]
    } else {
        pol <- NULL
    }
    localXyplot(formula, data = p, panel = panel,  aspect = aspect,
                biplot = env, polygon = pol, type = type, ...)
}