r - 如何在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 表中查看此列表列表。
解决方案
我们可以试试这个:
write.csv(do.call("rbind",list(unlist(a))),"testme.csv")
你也可以试试这个并reshape2
在导出前做一些事情。
write.csv(do.call("cbind",list(unlist(a))),"testme2.csv")
查看这些产生的结构:
View(do.call("cbind",list(unlist(a))))
@jay.sf 建议的另一个选项:
openxlsx::write.xlsx(do.call("rbind",list(unlist(a))),"testme.xlsx")
推荐阅读
- python-3.x - socket.send和socket.recv,一个接一个使用,导致客户端与服务器通信不同步Python3
- c - alloca 代替 alsa 中的局部变量
- azure - Azure Function App V2 是否可以使用超过 1.5 Gb 的内存
- python - 在 python XA = B 中求解线性方程
- ansible - 在转义发送到 shell 命令的字符串时遇到问题
- java - 双链表java反向函数报错
- c++ - C++ 关于指针和使用函数将它们初始化到堆中的行为到底是什么?
- html - 在 RShiny 中访问 HTML 单选按钮值
- amazon-web-services - Linux (Ubuntu) 上的 CPU 使用率下降
- android - 带有阴影的半透明覆盖在 android 上添加了内部“阴影”