我有一个像这样的矩阵:
X
[,1] [,2]
[1,] List,5 List,5
[2,] List,5 List,5
[3,] List,5 List,5
[4,] List,5 List,5
[5,] List,5 List,5
[6,] List,5 List,5
如何将其转换为数据框?
当我这样做时:
head(x[1,1],2)
[[1]]
DATE_TIME SITE RESPONSE_TIME AVAIL_PERCENT AGENT
1 2013-MAY-24 05:09 PM Keynote Business 40 TxP - User Time (seconds)[Geo Mean] - - 45693
2 2013-MAY-24 05:24 PM Keynote Business 40 TxP - User Time (seconds)[Geo Mean] - - 45693
3 2013-MAY-24 05:39 PM Keynote Business 40 TxP - User Time (seconds)[Geo Mean] - - 45693
4 2013-MAY-24 05:54 PM Keynote Business 40 TxP - User Time (seconds)[Geo Mean] - - 45693
5 2013-MAY-24 06:09 PM Keynote Business 40 TxP - User Time (seconds)[Geo Mean] - - 45693
答案 0 :(得分:0)
要解决的第一件事是列表矩阵中的位置是否有任何意义。如果你只想“扁平化”它,你可以这样做:
# Not workig : out <- do.call( as.data.frame, c(x) )
# Then try:
out <- do.call( rbind, as.list(x) )
如果您需要记录位置,则需要使用标记输出的方法,可能使用apply
或一次处理一个矩阵列。