]> git.donarmstrong.com Git - ape.git/blobdiff - R/write.tree.R
bug fix in write.tree()
[ape.git] / R / write.tree.R
index 08747b99c672a993d6ead68efd3623ea64a173ff..08de505eaf78f90db4a2000a94d7dd733b3eaa9e 100644 (file)
@@ -1,4 +1,4 @@
-## write.tree.R (2010-11-08)
+## write.tree.R (2010-12-07)
 
 ##   Write Tree File in Parenthetic Format
 
@@ -30,7 +30,7 @@ checkLabel <- function(x, ...)
 write.tree <-
     function(phy, file = "", append = FALSE, digits = 10, tree.names = FALSE)
 {
-    if (!(inherits(phy, "phylo") || inherits(phy, "multiPhylo")))
+    if (!(inherits(phy, c("phylo", "multiPhylo"))))
         stop("object \"phy\" has no trees")
 
     if (inherits(phy, "phylo")) phy <- c(phy)
@@ -73,7 +73,7 @@ write.tree <-
             if (j != desc[length(desc)]) cp(",")
         }
         cp(")")
-        if (nodelab && ind[i] > n) cp(phy$node.label[ind[i] - n])
+        if (nodelab && i > n) cp(phy$node.label[i - n]) # fixed by Naim Matasci (2010-12-07)
         if (brl) {
             cp(":")
             cp(sprintf(f.d, phy$edge.length[ind[i]]))