Bert Gunter 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 us
Without any error checking, I'd try this:
recurse <-
function(l1,l2){
if(is(l1[[1]],"list"))
mapply(recurse,l1,l2,SIMPLIFY=F) else
{mapply(c,l1,l2,SIMPLIFY=F)}
}
recurse(list.1,list.2)
which recursively traverses each tree (list) in tandem until one is not
composed o
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 le
On Tue, 11 Jan 2011, Georg Otto wrote:
Dear R gurus,
first let me apologize for a question that might hve been answered
before. I was not able to find the solution yet. I want to concatenate
two lists of lists at their lowest level.
Suppose I have two lists of lists:
list.1 <- list("I"=list(
Hi Georg,
This was an interesting challenge to me. Here's what I came up with.
The first option meets your desired result, but could get messy with
deeper nesting. The second is less code, but is not quite what you
want and requires as.data.frame() to give a reasonable result for each
list. Cal
Dear R gurus,
first let me apologize for a question that might hve been answered
before. I was not able to find the solution yet. I want to concatenate
two lists of lists at their lowest level.
Suppose I have two lists of lists:
list.1 <- list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f")
6 matches
Mail list logo