Skip to content
Prev 247055 / 398503 Next

list concatenation

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 of lists and then concatenates. If the structure of the lists does
not agree, this will fail.

Regards,

David Katz
david at davidkatzconsulting.com