Description Usage Arguments Details Author(s) Examples
Flatten a nested list to a one-level list
1 | list.flatten(x, use.names = TRUE, classes = "ANY")
|
x |
|
use.names |
|
classes |
A character vector of class names, or "ANY" to match any class. |
The function is essentially a slightly modified version of flatten2
provided by Tommy at stackoverflow.com who
has full credit of the implementation of this function.
1 2 3 4 5 6 | p <- list(a=1,b=list(b1=2,b2=3),c=list(c1=list(c11='a',c12='x'),c2=3))
list.flatten(p)
p <- list(a=1,b=list(x="a",y="b",z=10))
list.flatten(p, classes = "numeric")
list.flatten(p, classes = "character")
|
$a
[1] 1
$b.b1
[1] 2
$b.b2
[1] 3
$c.c1.c11
[1] "a"
$c.c1.c12
[1] "x"
$c.c2
[1] 3
$a
[1] 1
$b.z
[1] 10
$b.x
[1] "a"
$b.y
[1] "b"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.