我最近找到了该zoo
功能na.approx
,但想知道是否有一种方法可以在不改变时区显示方式的情况下使用它,如运行我的可重现示例所示...
set.seed(111)
x <- xts(matrix(cumprod(rnorm(100,0,0.001)+1)*100,
ncol=1,dimnames=list(rep("",100),c("JJ"))),
Sys.time()-c(100:1), tzone="America/Chicago")
x[30:50,] <- NA
tzone(x)
[1] "America/Chicago"
.index(head(x,1))
[1] 1377270598
attr(,"tzone")
[1] "America/Chicago"
attr(,"tclass")
[1] "POSIXct" "POSIXt"
head(x)
JJ
2013-08-23 10:09:57 100.02352
2013-08-23 10:09:58 99.99044
2013-08-23 10:09:59 99.95928
2013-08-23 10:10:00 99.72914
2013-08-23 10:10:01 99.71210
2013-08-23 10:10:02 99.72609
Warning message:
timezone of object (America/Chicago) is different than current timezone ().
y <- na.approx(x)
tzone(y)
[1] "America/Chicago"
.index(head(y,1))
[1] 1377270598
head(y)
JJ
2013-08-23 16:09:57 100.02352
2013-08-23 16:09:58 99.99044
2013-08-23 16:09:59 99.95928
2013-08-23 16:10:00 99.72914
2013-08-23 16:10:01 99.71210
2013-08-23 16:10:02 99.72609
Warning message:
timezone of object (America/Chicago) is different than current timezone ().
注意我不在芝加哥....而且我Sys.getenv('TZ')
没有设置为"America/Chicago"