[R] list concatenation

Georg Otto gwo at well.ox.ac.uk
Wed Jan 12 12:50:57 CET 2011


Bert Gunter <gunter.berton at gene.com> writes:

> Lists are (isomorphic to) trees with (possibly) labelled nodes. A
> completely general solution in which two trees have possibly different
> topologies and different labels would therefore involve identifying
> the paths to leaves on each tree, e.g. via depth first search using
> recursion, and unioning leaves with the same paths (which could be
> quickly found in R via match() on the paths). This is a standard
> exercise in a data structures course.
>
> Considerable simplification could be effected if tree topologies
> and/or labels are identical or have other restrictions on them.
> However, you have not made it clear in your post whether this is the
> case (it is in your example).
>

Thanks so much to all of you for your very helpful suggestions, that
helped me solve my problem.

The tree topologies are indeed identical, so the suggested solutions did
work, but just for me to learn: Can somebody point me to how a general
solution mentioned by Bert would look like?

Cheers,

Georg



More information about the R-help mailing list