R/cophenetic.spantree.R

Defines functions `cophenetic.spantree`

`cophenetic.spantree` <-
    function(x)
{
    n <- x$n
    mat <- matrix(NA, nrow=n, ncol=n)
    if (n < 2)
        return(as.dist(mat))
    ind <- apply(cbind(2:n, x$kid), 1, sort)
    ind <- t(ind[2:1,])
    mat[ind] <- x$dist
    d <- as.dist(mat)
    attr(d, "Labels") <- x$labels
    stepacross(d, path = "extended", toolong=0, trace=FALSE)
}

Try the vegan package in your browser

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

vegan documentation built on Sept. 11, 2024, 7:57 p.m.