将列表中的每个项目转换为数据帧R中的单独列

时间:2013-10-28 19:46:00

标签: r

我有一个长度为0f 173的列表,每个元素包含48个项目。我想制作一个最终有48行和173列的数据帧。这些项目的名称并不重要,所以我怎么做?

dput(tra[[1]][1:5,1:5])
structure(list(c..0.0....93.. = structure(c(1L, NA, NA, NA, NA
), .Label = c("0|0", "93"), class = "factor"), c..0.0....127.. = structure(c(1L, 
NA, NA, NA, NA), .Label = c("0|0", "127"), class = "factor"), 
    c..0.0....127...1 = structure(c(1L, NA, NA, NA, NA), .Label = c("0|0", 
    "127"), class = "factor"), c..0.0....127...2 = structure(c(1L, 
    NA, NA, NA, NA), .Label = c("0|0", "127"), class = "factor"), 
    c..0.0....127...3 = structure(c(1L, NA, NA, NA, NA), .Label = c("0|0", 
    "127"), class = "factor")), .Names = c("c..0.0....93..", 
"c..0.0....127..", "c..0.0....127...1", "c..0.0....127...2", 
"c..0.0....127...3"), row.names = c("1", "NA", "NA.1", "NA.2", 
"NA.3"), class = "data.frame")

我试过了:

> ft <- data.frame(matrix(unlist(tra), nrow=173, byrow=T))
Error in matrix(unlist(tra), nrow = 173, byrow = T) : 
'data' must be of a vector type, was 'NULL'
AND 
> traa <- do.call(rbind.data.frame, tra)
Error in match.names(clabs, names(xi)) : 
names do not match previous names

0 个答案:

没有答案