Wednesday, 28 August 2013

How can I flatten two lists within a list without using data.table?

How can I flatten two lists within a list without using data.table?

I would like to form one data.frame from lists within a list
L1 <- list(A = c(1, 2, 3), B = c(5, 6, 7))
L2 <- list(A = c(11, 22, 33), B = c(15, 16, 17))
L3 <- list(L1, L2)
L3
library(data.table)
According to the 'data.table' manual : "'rbindlist' Same as
do.call("rbind",l), but much faster"
I would like to achieve what 'rbindlist' does using R base package
rbindlist does exactly what I need but 'do.call' does not!
rbindlist(L3)
do.call does not do what I want
do.call(rbind, L3)
identical(rbindlist(L3), do.call(rbind, L3))

No comments:

Post a Comment