【问题标题】:Timezone issue when filtering XTS using .indexhour使用 .indexhour 过滤 XTS 时的时区问题
【发布时间】:2015-01-14 21:17:41
【问题描述】:

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

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 对象时区。

有什么办法可以解决吗?

【问题讨论】:

    标签: r timezone xts


    【解决方案1】:

    这是bug #5891,自revision 844 起已在R-Forge 上进行了修补。

    【讨论】:

      猜你喜欢
      • 2018-03-19
      • 2018-07-27
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      • 2016-07-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多