I researched ways to write this type of list, but I could not achieve.
Here is my data:
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"))
I need to see this list of lists in a excel sheet.
We could try this:
write.csv(do.call("rbind",list(unlist(a))),"testme.csv")
You could also try this and do some reshape2
ing before export.
write.csv(do.call("cbind",list(unlist(a))),"testme2.csv")
Viewing the structure these yield:
View(do.call("cbind",list(unlist(a))))
Another option as suggested by @jay.sf :
openxlsx::write.xlsx(do.call("rbind",list(unlist(a))),"testme.xlsx")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.