使用 .indexhour 过滤 XTS 时的时区问题 [英] Timezone issue when filtering XTS using .indexhour

查看:28
本文介绍了使用 .indexhour 过滤 XTS 时的时区问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下 R 代码返回意外输出:

The following R code returns an unexpected output:

times = c("2014-12-01 15:59:00", "2014-12-01 16:00:00", "2014-12-01 16:01:00")
values = c(64.23, 64.43, 64.31)
tim <- as.POSIXct(c("2014-12-01 15:59:00", "2014-12-01 16:00:00", "2014-12-01 16:01:00"), tz="GMT")
myts <- xts(values, tim, tzone="GMT")
print(myts[.indexhour(myts)==16])

我明白了:

                     [,1]
2014-12-01 15:59:00 64.23

虽然我希望:

                     [,1]
2014-12-01 16:00:00 64.43
2014-12-01 16:01:00 64.31

我认为 .indexhour 以某种方式指的是我的本地时区,而我显然希望它使用 XTS 对象时区.

I think .indexhour is somehow referring to my local timezone, while I obviously expect it to use the XTS object timezone.

我能做些什么来修复它吗?

Is there anything I can do to fix it?

推荐答案

这是错误 #5891 并且已从 修订版 844.

这篇关于使用 .indexhour 过滤 XTS 时的时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆