데이터에 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