这一定很简单,但我似乎找不到解决方案。我需要比较Close
2 个xts
对象的值
我有 2 个xts
对象:
>low2
low2 daco.Close
2013-07-24 6.63
>low3
low3 daco.Close
2013-07-24 2.63
但是当我尝试这样的事情时
if(low2$daco.Close < low3$daco.Close) {...}
我不断收到错误
Error in if (low2$daco.Close < low3$daco.Close) { :
argument is of length zero
即使当我尝试print(low2)
或print(low3)
我得到正确的值时。
任何有关如何解决此问题的提示将不胜感激。谢谢!
编辑:以下是和的low2
输出low3
> dput(low2)
structure(6.63, .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", src = "xxx", updated = structure(1374782893.98805, class = c("POSIXct",
"POSIXt")), class = c("xts", "zoo"), index = structure(1374451200, tzone = "UTC", tclass = "Date"), .Dim = c(1L,
1L), .Dimnames = list(NULL, "daco.Close"))
> dput(low3)
structure(2.63, .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", src = "xxx", updated = structure(1374782893.98805, class = c("POSIXct",
"POSIXt")), class = c("xts", "zoo"), index = structure(1374624000, tzone = "UTC", tclass = "Date"), .Dim = c(1L,
1L), .Dimnames = list(NULL, "daco.Close"))