时区,period.apply在xts中使用R

时区,period.apply在xts中使用R,r,timezone,apply,xts,posixct,R,Timezone,Apply,Xts,Posixct,我在一个带有GMT时区的xts对象中有一组1分钟的数据。我打电话 period.apply (obj, endpoints(obj, "hours")) 由于某种原因,我的新对象的时区更改为EST/EDT,但是,当我执行str(obj)时,它仍然表示时区为GMT。下面是一个示例: obj1 <- xts(1:200, order.by=index(ret_1_min_xts)[1:200]) head(obj1) [,1] 1986-02-04 1

我在一个带有GMT时区的
xts
对象中有一组1分钟的数据。我打电话

period.apply (obj, endpoints(obj, "hours"))
由于某种原因,我的新对象的时区更改为EST/EDT,但是,当我执行
str(obj)
时,它仍然表示时区为GMT。下面是一个示例:

obj1 <- xts(1:200, order.by=index(ret_1_min_xts)[1:200])
head(obj1)
                    [,1]
1986-02-04 14:32:00    1
1986-02-04 14:33:00    2
1986-02-04 14:34:00    3
1986-02-04 14:35:00    4
1986-02-04 14:36:00    5
1986-02-04 14:37:00    6
Warning message:
   timezone of object (GMT) is different than current timezone (). 
这是一条重要线索

Warning message:
  timezone of object (GMT) is different than current timezone ()
它正在系统的时区中显示。您可以这样设置系统的时区

Sys.setenv(TZ="GMT")
然后,您的
xts
将打印GMT时区

Sys.setenv(TZ="GMT")