Why is this xts frequency always 1?

旧时模样 提交于 2019-12-01 08:27:20

Consecutive Date class dates always have a frequency of 1 since consecutive dates are 1 apart. Use ts or zooreg to get a frequency of 7:

tt <- ts(values, frequency = 7)

library(zoo)
zr <- as.zooreg(tt)
# or
zr <- zooreg(values, frequency = 7)

These will create a series whose times are 1, 1+1/7, 1+2/7, ...

If we have some index values of zr

zrdates <- index(zr)[5:12]

we can recover the dates from zrdates like this:

days[match(zrdates, index(zr))]

As pointed out in the comments xts does not support this type of series.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!