[Phylobase-commits] r377 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 20 22:40:36 CET 2008
Author: bbolker
Date: 2008-12-20 22:40:36 +0100 (Sat, 20 Dec 2008)
New Revision: 377
Modified:
pkg/R/setAs-Methods.R
Log:
tweaked for roundtrip phylo to phylo4 consistency
Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R 2008-12-20 21:10:41 UTC (rev 376)
+++ pkg/R/setAs-Methods.R 2008-12-20 21:40:36 UTC (rev 377)
@@ -50,10 +50,13 @@
if (inherits(from,"phylo4d"))
warning("losing data while coercing phylo4d to phylo")
brlen <- from at edge.length
- if (isRooted(from)) brlen <- brlen[nodeId(from,"all")!=rootNode(from)]
- edgemat <- na.omit(from at edge)
- y <- list(edge = na.omit(from at edge), edge.length = brlen,
- Nnode = from at Nnode, tip.label = from at tip.label,
+ rootpos <- which(nodeId(from,"all")==rootNode(from))
+ if (isRooted(from)) brlen <- brlen[-rootpos]
+ edgemat <- unname(from at edge[-rootpos,])
+ y <- list(edge = edgemat,
+ Nnode = from at Nnode,
+ tip.label = from at tip.label,
+ edge.length = brlen,
node.label = from at node.label)
class(y) <- "phylo"
if (length(y$edge.length) == 0)
More information about the Phylobase-commits
mailing list