I have a list that has to be converted to a table, but has to return to its list state.
li <- list(list(id = 1, v = 2), list(id = 1, v = 3))
tab <- dplyr::bind_rows(li)
tab
# A tibble: 2 × 2
id v
<dbl> <dbl>
1 1 2
2 1 3
How do I return to li
?
Edit: purrr::transpose does the trick. # now superseded
Edit 2: as.list() |> purrr::list_transpose() does it
purrr::list_transpose(as.list(tab))
[[1]]
[[1]]$id
[1] 1
[[1]]$v
[1] 2
[[2]]
[[2]]$id
[1] 1
[[2]]$v
[1] 3