在 R xts 中显示时间索引
我想用微秒定时索引解析 csv。 所以,我编写了这样的代码:
t<-read.zoo("test", index.column = 1, sep=",",header=TRUE, format="%Y-%m-%d %H:%M:%OS")
t.xts<-as.xts(t)
之后,我尝试显示此内容,但在索引上看不到时间信息。
> t.xts[1:10,4]
drate
2010-09-28 " -149"
2010-09-28 " -269"
2010-09-28 " -358"
2010-09-28 " -358"
2010-09-28 " -239"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -119"
2010-09-28 " -149"
我尝试了 options(digits.secs=6) 但没有成功。
I want to parse csv with micro-second timed index.
So, I wrote code like this:
t<-read.zoo("test", index.column = 1, sep=",",header=TRUE, format="%Y-%m-%d %H:%M:%OS")
t.xts<-as.xts(t)
after then, I tried to display this but I couldn't see time information on the index.
> t.xts[1:10,4]
drate
2010-09-28 " -149"
2010-09-28 " -269"
2010-09-28 " -358"
2010-09-28 " -358"
2010-09-28 " -239"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -119"
2010-09-28 " -149"
I tried options(digits.secs=6) but didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以提供 CSV 文件中的几行内容,将会有所帮助。设置
options(digits.secs=6)
对我有用。您还可以尝试使用indexFormat
手动设置格式。It would help if you could provide a few lines from your CSV file. Setting
options(digits.secs=6)
works for me. You could also try manually setting the format withindexFormat
.