[Phylobase-commits] r438 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 17 17:58:34 CEST 2009


Author: regetz
Date: 2009-06-17 17:58:33 +0200 (Wed, 17 Jun 2009)
New Revision: 438

Modified:
   pkg/R/setAs-Methods.R
Log:
fixed phylo->phylo4 coercion in cases of only 1 internal node (bug #441)


Modified: pkg/R/setAs-Methods.R
===================================================================
--- pkg/R/setAs-Methods.R	2009-04-26 17:28:17 UTC (rev 437)
+++ pkg/R/setAs-Methods.R	2009-06-17 15:58:33 UTC (rev 438)
@@ -5,7 +5,11 @@
     ## TODO should we also attempt to get order information?
     if (is.rooted(from)) {
         tip.idx <- 1:nTips(from)
-        int.idx <- (nTips(from)+1):dim(from$edge)[1]
+        if (nTips(from) < nrow(from$edge)) {
+            int.idx <- (nTips(from)+1):dim(from$edge)[1]
+        } else {
+            int.idx <- NULL
+        }
         root.node <- as.numeric(setdiff(unique(from$edge[,1]), unique(from$edge[,2])))
 
         from$edge <- rbind(from$edge[tip.idx,],c(NA,root.node),from$edge[int.idx,])



More information about the Phylobase-commits mailing list