[英]R: combine list of lists into a single dataframe
I have a list (res) containing pxb number of dataframes. 我有一个列表(res)包含pxb个数据帧。 Each dataframe has 12 columns but varying number of rows (eg,
res[[1]][[1]]
has 12 cols and 36 rows, but res[[1]][[1]]
has 12 cols and 38 rows). 每个数据帧有12列,但行数不同(例如,
res[[1]][[1]]
有12列和36行,而res[[1]][[1]]
有12列和38行) 。 I would like to combine them into a single dataframe that has 12 columns and 179 rows let's say. 我想将它们组合成一个具有12列和179行的单个数据框。 The
do.call("rbind", listOfDataFrames)
method doesn't work as I loose column and row information. 由于我丢失了列和行信息
do.call("rbind", listOfDataFrames)
所以do.call("rbind", listOfDataFrames)
方法不起作用。 Let me know, if further specification is needed. 让我知道,是否需要进一步的说明。 Many thanks!
非常感谢!
In fact it is a list containing 5
elements. 实际上,它是一个包含
5
元素的列表。 And the first element is a list of dataframes, whereas the other elements 2
, 3
, 4
and 5
are NULL
. 并且所述第一元件是dataframes的列表,而在其他元件
2
, 3
, 4
和5
是NULL
。 so you need to do access the first element of your list: 因此您需要访问列表的第一个元素:
do.call(rbind, listOfDataFrames[[1]])
Or: 要么:
rbindlist(listOfDataFrames[[1]])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.