如何在R中导出具有不同大小的列表列表

时间:2019-03-30 09:00:18

标签: r

我研究了编写此类列表的方法,但未能实现。

这是我的数据:

a<-structure(list(X2005 = structure(list(hours = list(c(0.2, 0, 
4), c(0.2, 4)), maxx = structure(list(maxh2 = 4, maxh3 = 4), .Names = c("maxh2", 
"maxh3"))), .Names = c("hours", "maxx")), X2006 = structure(list(
    hours = list(c(1.8, 0, 1), c(1.8, 1)), maxx = structure(list(
        maxh2 = 1.8, maxh3 = 1.8), .Names = c("maxh2", "maxh3"
    ))), .Names = c("hours", "maxx")), X2007 = structure(list(
    hours = list(c(4.2, 0, 0), c(4.2, 0)), maxx = structure(list(
        maxh2 = 4.2, maxh3 = 4.2), .Names = c("maxh2", "maxh3"
    ))), .Names = c("hours", "maxx")), X2008 = structure(list(
    hours = list(c(0.1, 6, 0), c(3.1, 3)), maxx = structure(list(
        maxh2 = 6, maxh3 = 3.1), .Names = c("maxh2", "maxh3"))), .Names = c("hours", 
"maxx"))), .Names = c("X2005", "X2006", "X2007", "X2008"))

我需要在Excel工作表中查看此列表列表。

1 个答案:

答案 0 :(得分:2)

我们可以尝试一下:

simpletable

您也可以尝试此操作,并在导出前进行一些write.csv(do.call("rbind",list(unlist(a))),"testme.csv") 的操作。

reshape2

查看这些结构会产生以下结果:

write.csv(do.call("cbind",list(unlist(a))),"testme2.csv")

@ jay.sf建议的另一个选项:

View(do.call("cbind",list(unlist(a))))