[R] Compare two lists, with their sublists that have same structure
gunter.berton at gene.com
Sat Oct 26 20:21:54 CEST 2013
Warning: This may not be helpful.
If I understand you correctly, you have two arbitrary lists of the
same structure whose contents you wish to "compare." You have not
specified exactly what sort of comparison you wish to make, e.g. just
"are they the same?" or "What is the nature of any differences?" ...
In any case, R lists are generic recursive structures, equivalent to
trees. So you may find something useful by searching on "recursive
tree walking in R" or some such, although I was not able to in a brief
But more to the point, and again if I understand you correctly, what
you seek is a way to walk arbitrary lists and "compare" them. This is
not hard, but I think it requires writing a recursive algorithm in R,
which is a bit tricky, and might be too much to ask if you have no
experience with such things. I have a little, so it would probably
take me a day, as compared to under an hour for someone skilled in
such things. Maybe you'll get a more helpful response from someone
with such skills.Or someone can point you to such existing
You also might want to have a look at the ?rapply function, although
I didn't see how it immediately applied; but its name suggests it
might, so maybe I missed something.
Anyway, my message is that this may be a fairly tricky task if a
general solution is wanted, so either provide more details so that
someone can give you something that fits your specific needs (small,
reproducible examples are really useful for this), look around to see
if you can find something that handles the general task, or hope that
all my words will prod someone with more smarts to help.
On Sat, Oct 26, 2013 at 10:17 AM, Alaios <alaios at yahoo.com> wrote:
> Dear all,
> I would like to ask your help concering two R lists.
> If I did everything should have the same structure (that means the same number of sublists, and their sublists also the same number of sublists). What would change between the two lists is the contents of each element in the lists.
> Could you please help me understand how I can do that in R?
> I would like to thank you in advance for your help
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Genentech Nonclinical Biostatistics
More information about the R-help