Skip to content
Back to formatted view

Raw Message

Message-ID: <912A2028-AEA3-474B-A315-2AFF84ABAFFF@gmx.de>
Date: 2010-01-08T15:35:27Z
From: Mark Heckmann
Subject: how to flatten a list to the same level?

I have a nested list l like:

l <- list(A=c(1,2,3), B=c("a", "b"))
l <- list(l,l, list(l,l))

I want the list to be unlisted, but not on the lowest level of each  
"branch".
I want the lowest level of each list branch to remain as it is.
So unlist or unlist(rec=F) do not work here as the level of nesting  
may differ on the elements.
The result should look like:

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

$A
[1] 1 2 3

$B
[1] "a" "b"

Any ideas?
TIA!

Mark


???????????????????????????????????????
Mark Heckmann
Dipl. Wirt.-Ing. cand. Psych.
Vorstra?e 93 B01
28359 Bremen
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com