2015-04-27 16 views
2

我剛剛面對我發現一個非常奇怪的行爲與xts對象。如果我在xts對象上使用比較運算符,則會失去它的時區屬性。我還沒有遇到過任何其他運營商的這種結果。R xts失去時區屬性

> a=matrix(seq(1,4),ncol=2,nrow=2) 
> a=xts(a, order.by=as.POSIXct(seq(1,2), origin="1970-01-01", tz="GMT")) 
> a 
        [,1] [,2] 
1970-01-01 00:00:01 1 3 
1970-01-01 00:00:02 2 4 
Warning message: 
timezone of object (GMT) is different than current timezone(). 


> a>0 
        [,1] [,2] 
1970-01-01 01:00:01 TRUE TRUE 
1970-01-01 01:00:02 TRUE TRUE 

這是預期的行爲還是xts實施中的錯誤?

+1

'sessionInfo()'來檢查哪個版本的'xts' – RUser

+0

歡迎來到SO!我可以用'xts_0.9-7'和'R 3.2.0',win7來確認。 – tonytonov

+2

但它適用於'xts_0.9.874'。這就是爲什麼'sessionInfo()'是有用的。 –

回答

1

更新 - xts包:install.packages("xts", repos="http://R-Forge.R-project.org")link

> a>0 
        [,1] [,2] 
1970-01-01 00:00:01 TRUE TRUE 
1970-01-01 00:00:02 TRUE TRUE 
Warning message: 
timezone of object (GMT) is different than current timezone(). 

> sessionInfo() 
R version 3.1.2 (2014-10-31) 
Platform: x86_64-w64-mingw32/x64 (64-bit) 


other attached packages: 
[1] xts_0.9.874 zoo_1.7-10 

loaded via a namespace (and not attached): 
[1] grid_3.1.2  lattice_0.20-29 tools_3.1.2