Wednesday, February 27, 2013

New phytools build and rep() function for "phylo" objects

I just posted a new minor version of 'phytools' (phytools 0.2-22). You can download it here, and install from source.

Relative to the last minor version, this version has only the new function writeAncestors, as well as a function called internally by writeAncestors called repPhylo. repPhylo merely does what the 'base' function rep does for vectors and lists, but for "phylo" objects. This turned out to be annoyingly difficult, until I realized that I could work from this solution on stackoverflow.com.

Here it is, modified for "phylo" objects:
repPhylo<-function(tree,times){
 tree<-
 if(sum(sapply(tree,class)!="list")==0){
   tree
 } else {
     list(tree)
 }
 tree<-rep(tree,length=times)
 class(tree)<-"multiPhylo"
 return(tree)
}

No comments:

Post a Comment