私は自分のデータがUTCタイムゾーンにあるので、私はAmerica/New_York
にそれらをシフトすることができると教えてください。しかし、私がindexTZ()
を使うと時間が変わります。xtsのタイムゾーンを変更する方法
16:00 UTC時間を12:00 NY時間にします。
test = read.zoo(paste0(datadir,"test_.csv"),
index = 1,FUN = as.POSIXct, header = T, sep = ",")
test = as.xts(test)
head(test)
> QQQ.Open QQQ.High QQQ.Low QQQ.Close QQQ.Volume
>
> 2016-09-10 16:38:00 4665.75 4665.75 4665.75 4665.75 1
> 2016-09-11 14:13:00 4665.75 4665.75 4665.75 4665.75 1
> 2016-09-11 22:01:00 4661.25 4667.25 4657.25 4666.75 932
> 2016-09-11 22:02:00 4666.75 4667.25 4663.25 4665.00 174
> 2016-09-11 22:03:00 4665.00 4667.00 4665.00 4666.50 66
indexTZ(test)<- "UTC"
head(test)
QQQ.Open QQQ.High QQQ.Low QQQ.Close QQQ.Volume
2016-09-10 20:38:00 4665.75 4665.75 4665.75 4665.75 1
2016-09-11 18:13:00 4665.75 4665.75 4665.75 4665.75 1
2016-09-12 02:01:00 4661.25 4667.25 4657.25 4666.75 932
2016-09-12 02:02:00 4666.75 4667.25 4663.25 4665.00 174
2016-09-12 02:03:00 4665.00 4667.00 4665.00 4666.50 66
Warning message:
timezone of object (UTC) is different than current timezone().
> test_dt$hour1 = strftime(test_dt$index, format = "%H", tz = "America/New_York")
> test_dt$hour2 = strftime(test_dt$index, format = "%H", tz = "UTC")
> table(test_dt$hour1)
14 16 22
1 1 3
> table(test_dt$hour2)
02 18 20
3 1 1