This can actually be done with stack
from base R:
stack(lst)
values ind
1 248269 multiinstrumentais
2 248827 multiinstrumentais
3 248198 geds
4 248198 geds
5 248857 geds
6 248087 ghzmb
7 296994 ghzmb
8 302862 ghzmb
Here's another solution with dplyr
and tibble
, though this adds a number to the end of the row name, you can remove it by adding mutate(rowname = str_remove(rowname, pattern = '[[:digit:]]+'))
to the chain:
library(tibble)
library(dplyr)
lst %>%
unlist() %>%
as.tibble() %>%
rownames_to_column()
Returns:
# A tibble: 8 x 2
rowname value
<chr> <chr>
1 multiinstrumentais1 248269
2 multiinstrumentais2 248827
3 geds1 248198
4 geds2 248198
5 geds3 248857
6 ghzmb1 248087
7 ghzmb2 296994
8 ghzmb3 302862
Or with tidyr
and dplyr
, this seems to work:
lst %>%
unlist() %>%
bind_rows() %>%
gather()
# Alternatively, this one liner
tidyr::gather(bind_rows(unlist(lst)))
Using Val's data:
lst<- list(
multiinstrumentais=c("248269","248827"),
geds=c("248198","248198","248857"),
ghzmb=c("248087","296994","302862")
)