Edited :
I think I rushed to answer. I need to go slower
EDIT 2 :
this issue is because bind_rows wants to work on dataframes as inputs , not plain lists... so the approach I show below wraps up the lists as one row dataframes that an be bind_rows()'ed together
The first way is explicit, the second implicit, using purrr packages map_dfr()
testL <-
list(s = structure(c(`21` = 1590L, `22` = 1417L, `23` = 505L,
`24` = 137L, `41` = 32L, `42` = 14L, `43` = 18L, `90` = 8L), .Dim = 8L, .Dimnames = structure(list(
c("21", "22", "23", "24", "41", "42", "43", "90")), .Names = ""), class = "table"),
t = structure(c(`21` = 192L, `22` = 800L, `23` = 437L, `24` = 123L
), .Dim = 4L, .Dimnames = structure(list(c("21", "22", "23",
"24")), .Names = ""), class = "table"))
testL2 <- list( enframe(testL$s) %>%
pivot_wider(names_from = name,values_from = value),
enframe(testL$t) %>%
pivot_wider(names_from = name,values_from = value))
#check result
bind_rows(testL2)
## more elegantly ?
list_to_row_frame <- function(l) {
enframe(l) %>%
pivot_wider(names_from = name, values_from = value)
}
#library(purrr) # map_dfr is in purrr namespace
#another way
testL3 <- purrr::map_dfr(testL,~list_to_row_frame(.))