【发布时间】:2016-04-15 01:36:34
【问题描述】:
我正在尝试在下面编写.csv 大量数据透视表(根据表 b):
importer <- c("France", "Spain", "Germany", "France", "Spain", "France", "France", "France", "Germany")
exporter <- c("Peru", "Brazil", "Argentina", "Chile", "Chile", "Peru", "Peru", "Brazil", "Brazil")
goods <- c("Apples", "Wine", "Wine", "Cars", "Bananas", "Bananas", "Cars", "Bananas", "Wine")
df <-data.frame(importer, exporter, goods)
table_a <- table(df$importer, df$exporter)
write.csv(table_a, "table_a.csv")
table_b <- table(df$importer, df$exporter, df$goods)
write.csv(table_b, "table_b.csv")
但 CSV 输出采用平面格式 see table_b,我想按照正确的表格 see table a 显示。如果/如何实现这一目标有什么想法吗?
【问题讨论】:
-
你可以使用
?capture.output
标签: r csv pivot-table export-to-csv