[Mattice-commits] r195 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jun 1 08:59:53 CEST 2009


Author: andrew_hipp
Date: 2009-06-01 08:59:52 +0200 (Mon, 01 Jun 2009)
New Revision: 195

Modified:
   pkg/R/ouSim.ouchtree.R
Log:
ouSim.ouchtree works correctly now with zero-length branches

Modified: pkg/R/ouSim.ouchtree.R
===================================================================
--- pkg/R/ouSim.ouchtree.R	2009-05-29 22:31:04 UTC (rev 194)
+++ pkg/R/ouSim.ouchtree.R	2009-06-01 06:59:52 UTC (rev 195)
@@ -54,7 +54,8 @@
     for(i in seq(tree at nnodes)) branchList[[i]] <- rnorm(n = brLengths[i], mean = 0, sd = sdStep[i])
     }
   names(branchList) <- tree at nodes # branches are indexed by their end nodes
-  timesList <- lapply(branchList, seq) # creates a list of sequential numbers corresponding to the rnorm vectors
+  timesList <- lapply(lapply(branchList, length), seq) # creates a list of sequential numbers corresponding to the rnorm vectors
+  for(i in which(sapply(branchList, length) == 0)) timesList[[i]] <- numeric(0) # added b/c seq(numeric(0)) == 1:0
   startTimes <- round(unlist(sapply(tree at nodes, ancestorTime, tree = tree)) * steps) ## ASSUMES ULTRAMETRICITY
   for (i in 1:length(timesList)) timesList[[i]] <- timesList[[i]] + startTimes[i]
 



More information about the Mattice-commits mailing list