I have a list of vectors that I would like to convert into a dataframe.
Code
a <- list( c(1,2,3,4),
c(1,2,3,4),
c(4,5,6,3),
c(6,3,2,6))
With help of this post, I was able to do so in the following manner:
library(tidyverse)
a %>%
reduce(rbind) %>%
as.data.frame()
> a %>% reduce(rbind) %>% as.data.frame()
V1 V2 V3 V4
out 1 2 3 4
elt 1 2 3 4
elt.1 4 5 6 3
elt.2 6 3 2 6
I would like to use purrr
's bind_rows()
function (a %>% bind_rows
), as it seems more convenient. However, this generates an error:
Error: Argument 1 must have names.
Questions
- What is happening here?
- How can I prevent it from happening ;) ?