]> git.donarmstrong.com Git - ape.git/blobdiff - R/write.nexus.R
a few bug fixes especially in plot.phylo()
[ape.git] / R / write.nexus.R
index 4ee38f5083a6481917512b3ba382f8f41e454418..14f77341c498bfcd4a2f3bfbadffd905bdc3de2d 100644 (file)
@@ -1,8 +1,8 @@
-## write.nexus.R (2006-09-09)
+## write.nexus.R (2009-10-27)
 
 ##   Write Tree File in Nexus Format
 
-## Copyright 2003-2006 Emmanuel Paradis
+## Copyright 2003-2009 Emmanuel Paradis
 
 ## This file is part of the R-package `ape'.
 ## See the file ../COPYING for licensing issues.
@@ -14,7 +14,7 @@ write.nexus <- function(..., file = "", translate = TRUE, original.data = TRUE)
     if (length(obj) == 1) {
         if (class(obj[[1]]) == "phylo") ntree <- 1
         else {
-            obj <- unlist(obj, recursive = FALSE)
+            obj <- obj[[1]] # NOT use unlist()
             ntree <- length(obj)
         }
     } else ntree <- length(obj)
@@ -69,9 +69,11 @@ the original data won't be written with the tree."))
         token <- as.character(1:N)
         names(token) <- obj[[1]]$tip.label
         obj[[1]]$tip.label <- token
-        if (ntree > 1)
-          for (i in 2:ntree)
-            obj[[i]]$tip.label <- token[obj[[i]]$tip.label]
+        if (ntree > 1) {
+            for (i in 2:ntree)
+                obj[[i]]$tip.label <- token[obj[[i]]$tip.label]
+            class(obj) <- NULL
+        }
     } else {
         for (i in 1:ntree)
           obj[[i]]$tip.label <- checkLabel(obj[[i]]$tip.label)