X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fwrite.nexus.R;h=14f77341c498bfcd4a2f3bfbadffd905bdc3de2d;hb=d7105238f98acefc5fc0ad6278a515e682453b8b;hp=4ee38f5083a6481917512b3ba382f8f41e454418;hpb=c827059eeafc8cbe41c812b26979543ab287803e;p=ape.git diff --git a/R/write.nexus.R b/R/write.nexus.R index 4ee38f5..14f7734 100644 --- a/R/write.nexus.R +++ b/R/write.nexus.R @@ -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)