After using purrr:map
along a time series list column, I end up with the results in a tibble list (I may have some terminology wrong here, but hopefully the example will clear things up). Is it possible to extract each column in the resulting list as a data frame column without specifying each list element name?
Example data:
tmp <- tibble(col1 = c("A1", "A2") ,
col2 = c("B1", "B2"),
col3 = list(
list(x = TRUE, b = list(data.frame(y1=c(1,2,3), y2=c(4,5,6)))),
list(x = FALSE, b = list(data.frame(y1=c(1,2,3), y2=c(4,5,6))))))
Required output (but without having to type each column - in reality I have a lot more):
tmp %>% mutate(x = map(tmp$col3, "x")[[1]],
b = map(tmp$col3, "b")[[1]])
Edit: I have since realised my "manual solution" above is wrong.. I am not sure how to even extract b manually, but for x, it should have been:
tmp %>% mutate(x = map_lgl(col3, "x"))