Comparison of two great answers
There are two great one liner suggestions in this thread:
(1) cbind(df[1], t(data.frame(df$b)))
This is from @Onyambu using base R. To get to this answer one needs to know that a dataframe is a list and needs a bit of creativity.
(2) df %>% unnest_wider(b)
This is from @iago using tidyverse. You need extra packages and to know all the nest verbs, but one can think that it is more readable.
Now let's compare performance
library(dplyr) library(tidyr) library(purrr) library(microbenchmark) N <- 100 df <- tibble(a = 1:N, b = map2(1:N, 1:N, c)) tidy_foo <- function() suppressMessages(df %>% unnest_wider(b, names_sep = "-")) base_foo <- function() cbind(df[1],t(data.frame(df$b))) %>% as_tibble # To be fair microbenchmark(tidy_foo(), base_foo(), times = 1000)
Unit: milliseconds expr min lq mean median uq max neval tidy_foo() 6.538002 7.142651 7.935855 7.434001 7.945101 70.0057 1000 base_foo() 6.000001 6.423951 7.110651 6.636401 6.991952 13.8205 1000
Conclusion
tidyr solution is 1,1 times slower if you consider the mean but can generate worst case 5x times slower.
ListColis structured. If it contains a data frame or named list for each row, justtidyr::unnestwill work. If it's some other structure, you may need to rearrange first. To get a better answer, edit with the result of callingdputon your sample data so we can reproduce the exact structure.df$ListCol <- lapply(df$ListCol, function(x) as.data.frame(t(x)))(with dplyr and purrr, if you prefer) and then callingunnest.