Below works great, but I feel like there may be some tidyverse
verbs that I am missing (I was unnsuccessful trying to use map_dfr
and map_dfc
). In addition, I would love an approach that does not require me to specify value = "rec"
since it already has a name in the list.
library(tidyverse)
ll <- list(a = list(rec = c("one", "two"),
df = data.frame(x = 1:3, y = 3:1)),
b = list(rec = c("three", "four", "five"),
df = data.frame(x = 1:6, w = 6:1)))
ll %>%
map(1) %>%
enframe(name = "ID", value = "rec") %>%
unnest()
# # A tibble: 5 x 2
# ID rec
# <chr> <chr>
# 1 a one
# 2 a two
# 3 b three
# 4 b four
# 5 b five