-## 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.
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)
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)