R/orglsegments.R

`orglsegments` <-
    function (object, groups, order.by, display = "sites", choices = 1:3,
              col = "black", ...)
{
    pts <- scores(object, display = display, choices = choices, ...)
    ## order points along segments
    if (!missing(order.by)) {
        if (length(order.by) != nrow(pts))
            stop(gettextf("the length of order.by (%d) does not match the number of points (%d)",
                          length(order.by), nrow(pts)))
        ord <- order(order.by)
        pts <- pts[ord,]
        groups <- groups[ord]
    }
    inds <- names(table(groups))
    if (is.factor(col))
        col <- as.numeric(col)
    col <- rep(col, length = length(inds))
    names(col) <- inds
    for (is in inds) {
        X <- pts[groups == is, , drop = FALSE]
        if (nrow(X) > 1) {
            for (i in 2:nrow(X)) {
                segments3d(c(X[i-1,1],X[i,1]), c(X[i-1,2],X[i,2]), 
                          c(X[i-1,3],X[i,3]), col = col[is], ...)
            }
        }
    }
    invisible()
}

Try the vegan3d package in your browser

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

vegan3d documentation built on Feb. 16, 2023, 8:23 p.m.