[R] How to flatten a tree (based on list) to a certain depth?

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Feb 3 20:59:42 CET 2010

On Wed, Feb 3, 2010 at 2:37 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> On Wed, Feb 3, 2010 at 12:29 PM, Steve Lianoglou
>> Does `unlist(root, recursive=FALSE)` get you what you want?
> My example has only 2 levels.
> But my questions is not limited to a particular level. The
> nonrecursive version flatten the first level. But what if the tree is
> of n level and I want to flatten it to m levels (where m < n)?

I'm guessing you're going to have to write your own function for that
... using loops, or recursion.


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list