Skip to content
Back to formatted view

Raw Message

Message-ID: <1294765231968-3209324.post@n4.nabble.com>
Date: 2011-01-11T17:00:31Z
From: David Katz
Subject: list concatenation
In-Reply-To: <m2ei8jsavl.fsf@georgotto.de>

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
-- 
View this message in context: http://r.789695.n4.nabble.com/list-concatenation-tp3209182p3209324.html
Sent from the R help mailing list archive at Nabble.com.