xts comparison to another xts object does not work

試著忘記壹切 提交于 2019-12-01 10:38:27

xts logical operators work just like xts math operators. If both arguments are xts objects, the index values for both arguments have to match. In your case, m1 and m2 have different index values.

m1 > 0
#              one
# 2011-08-20 FALSE
m1 > m2
#     [,1]
m1
#               one
# 2011-08-20 -0.002
m2
#              one
# 2011-08-19 0.011

This is consistent with time series in general. You can't compare (or do any Ops) on values from differing time periods. xts in effect guards against behavior that can't happen naturally. If you need to compare one period to another, you'll need to force via coredata() or by using the lag() operators.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!