使用 .indexhour 过滤 XTS 时出现时区问题
Timezone issue when filtering XTS using .indexhour
以下 R 代码 returns 意外输出:
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 对象时区。
有什么办法可以解决吗?
这是bug #5891 and has been patched on R-Forge as of revision 844。
以下 R 代码 returns 意外输出:
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 对象时区。
有什么办法可以解决吗?
这是bug #5891 and has been patched on R-Forge as of revision 844。