t_list | R Documentation |
t_list
turns a list of lists inside-out. The performance is quite efficient regardless of the size of the list.
t_list(l)
l |
a list of lists. Elements inside the sublists can be heterogeneous, including further lists. |
l
transposed such that the second layer of the list becomes the top layer and the top layer the second layer. See Examples.
To transpose a data frame / list of atomic vectors see data.table::transpose()
.
rsplit
, List Processing, Collapse Overview
# Homogenous list of lists
l <- list(a = list(c = 1, d = 2), b = list(c = 3, d = 4))
str(l)
str(t_list(l))
# Heterogenous case
l2 <- list(a = list(c = 1, d = letters), b = list(c = 3:10, d = list(4, e = 5)))
attr(l2, "bla") <- "abc" # Attributes other than names are preserved
str(l2)
str(t_list(l2))
rm(l, l2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.