[R] list concatenation
David Katz
david at davidkatzconsulting.com
Tue Jan 11 18:00:31 CET 2011
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.
More information about the R-help
mailing list