将 XTS 导出为 CSV,带有单独的列
export XTS to CSV, with separate columns
我目前有一些时间序列数据,它是 XTS 格式的。这是其中的一部分。
head(dbt)
NSW1.Price Coal
2018-01-01 00:30:00 91.86 71.29267
2018-01-01 01:00:00 88.83 71.25520
2018-01-01 01:30:00 73.62 71.22649
2018-01-01 02:00:00 71.49 71.18284
2018-01-01 02:30:00 69.27 71.14081
2018-01-01 03:00:00 68.44 71.10430
我正在尝试将其导出到 CSV 文件,但是当我这样做时,它不会导出到单独的列中。这是我尝试导出它时发生的情况。
我使用的代码是
write.zoo(dbt,file="export.csv",index.name="okay",row.names=FALSE,col.names=TRUE)
你需要sep=","
.
直接来自 write.zoo
的帮助:
read.zoo and write.zoo are convenience functions for reading and writing "zoo"
series from/to text files. They are convenience interfaces to read.table and
write.table, respectively.
... further arguments passed to read.table, write.table, or read.zoo, respectively.
因此,这应该有效:
write.zoo(dbt,file="export.csv",index.name="okay",row.names=FALSE,col.names=TRUE,sep=",")
我目前有一些时间序列数据,它是 XTS 格式的。这是其中的一部分。
head(dbt)
NSW1.Price Coal
2018-01-01 00:30:00 91.86 71.29267
2018-01-01 01:00:00 88.83 71.25520
2018-01-01 01:30:00 73.62 71.22649
2018-01-01 02:00:00 71.49 71.18284
2018-01-01 02:30:00 69.27 71.14081
2018-01-01 03:00:00 68.44 71.10430
我正在尝试将其导出到 CSV 文件,但是当我这样做时,它不会导出到单独的列中。这是我尝试导出它时发生的情况。
我使用的代码是
write.zoo(dbt,file="export.csv",index.name="okay",row.names=FALSE,col.names=TRUE)
你需要sep=","
.
直接来自 write.zoo
的帮助:
read.zoo and write.zoo are convenience functions for reading and writing "zoo"
series from/to text files. They are convenience interfaces to read.table and
write.table, respectively.
... further arguments passed to read.table, write.table, or read.zoo, respectively.
因此,这应该有效:
write.zoo(dbt,file="export.csv",index.name="okay",row.names=FALSE,col.names=TRUE,sep=",")