[Vegan-commits] r1069 - pkg/vegan/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Nov 14 14:17:12 CET 2009
Author: jarioksa
Date: 2009-11-14 14:17:11 +0100 (Sat, 14 Nov 2009)
New Revision: 1069
Modified:
pkg/vegan/R/spandepth.R
Log:
fix spantree
Modified: pkg/vegan/R/spandepth.R
===================================================================
--- pkg/vegan/R/spandepth.R 2009-11-14 06:52:57 UTC (rev 1068)
+++ pkg/vegan/R/spandepth.R 2009-11-14 13:17:11 UTC (rev 1069)
@@ -5,6 +5,8 @@
`spandepth` <-
function (x)
{
+ if (!inherits(x, "spantree"))
+ stop("'x' must be 'spantree' result")
kid <- c(NA, x$kid)
par <- p <- seq_along(kid)
par[1] <- NA
@@ -13,8 +15,8 @@
intree <- p %in% kid | !is.na(kid)
depth <- numeric(length(par))
depth[intree] <- 1
- if (!is.null(tree$labels))
- names(depth) <- tree$labels
+ if (!is.null(x$labels))
+ names(depth) <- x$labels
while(any(intree)) {
## Node is internal (intree) if it is both a parent and a kid
## and kid is in the tree or it is kid to two or more parents
More information about the Vegan-commits
mailing list