Hello David,

Simply:

class(y) <- "multiPhylo"

Best,

Emmanuel
-----Original Message-----
From: David Bapst <dwba...@uchicago.edu>
Sender: r-sig-phylo-boun...@r-project.org
Date: Mon, 18 Jul 2011 19:02:17 
To: R Sig Phylo Listserv<r-sig-phylo@r-project.org>
Subject: [R-sig-phylo] Converting a List of Trees into a multiPhylo Object

Hello all,
I have a lapply() function which is outputting phylo objects (the input is a
list of complicated tables, each of which corresponds to a resulting tree,
long story).

The following is NOT what I'm doing, but gives you an idea of what the
result from lapply() looks like.

require(ape)
x<-list(5,10)
y<-lapply(x,rtree)

Unfortunately, this makes a list of trees (as can be shown with class(y) ),
not a multiPhylo object. Hrm.

One possibility, of course, is to use rmtree to make a placeholder and than
fill it with the original trees:

z<-rmtree(length(y),2)
for(i in 1:length(y)){z[[i]]<-y[[i]]}

...but that's kind of inelegant. I feel like there must be a simpler
solution.Is there any simple way to convert a list of trees into a
multiPhylo object?

-Dave


-- 
David Bapst
Dept of Geophysical Sciences
University of Chicago
5734 S. Ellis
Chicago, IL 60637
http://home.uchicago.edu/~dwbapst/

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to