[Phylobase-commits] r202 - branches/pdcgsoc/misc

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 14 19:41:00 CEST 2008


Author: pdc
Date: 2008-07-14 19:41:00 +0200 (Mon, 14 Jul 2008)
New Revision: 202

Modified:
   branches/pdcgsoc/misc/temp.R
Log:
simplify calc.node.xy()
combined all the actions that occur if we are at the root node

Modified: branches/pdcgsoc/misc/temp.R
===================================================================
--- branches/pdcgsoc/misc/temp.R	2008-07-14 17:38:11 UTC (rev 201)
+++ branches/pdcgsoc/misc/temp.R	2008-07-14 17:41:00 UTC (rev 202)
@@ -134,22 +134,15 @@
         if(any(phy at edge[, 2] == node) == FALSE) {
             decdex <- which(phy at edge[, 1] == node)
             index <- NULL
+            ## if root node start at x = 0
+            newx <- 0
         } else {
             ## non-root node behavior
             ## get row in edge matrix corresponding to node, get descendants
             index <- which(phy at edge[, 2] == node)
             decdex <- which(phy at edge[, 1] == phy at edge[index, 2])
-        }
-        if(is.null(index)) {
-            ## if root node start at x = 0
-            newx <- 0
-        } else {
             ## non-root node x location 
             newx <- xxyy$xx[index] <- phy at edge.length[index] + prevx
-        }
-        ## TODO this if can be combined with the above in the else section
-        # which might be able to go in the first if
-        if(!is.null(index)) {
             ## if the x value is already set we are at a tip and we return
             if(!is.na(xxyy$yy[index])) { return(xxyy) }
         }



More information about the Phylobase-commits mailing list