how to merge the elements of a list into a data frame? in R
dataframe, list, r
Solution
Try this:
as.data.frame(do.call(rbind, l))
where, `l <- list(1:5, 6:10)`
# V1 V2 V3 V4 V5
# 1 1 2 3 4 5
# 2 6 7 8 9 10
Problem
I have a list of elements, like this ``` [[1]] [1] 9.623571 5.334566 7.266597 6.510794 4.301958 [[2]] [1] 9.693326 9.015892 1.266178 8.547392 4.326199 ``` and I would like to transform it to dataframe like this: ``` V1 V2 V3 V4 V5 9.623571 5.334566 7.266597 6.510794 4.301958 9.693326 9.015892 1.266178 8.547392 4.326199 ``` Therefore, all elements in the same position within the entries of the list, merged in the same column. It has to be something related to "rbind", because the result is like doing: ``` rbind(list[[1]],list[[2]]...) ``` but I don't know how to apply it for all the entries of the list. Any light on this would be appreciated. Thank you very much in advance. Tina.