[R] testing xts values in if command?

ce zadig_1 at excite.com
Wed Jan 29 20:25:14 CET 2014


Dear all ,

xts objects give error in if command :
Error in if .... :
  missing value where TRUE/FALSE needed

> library(quantmod)
> getSymbols("SPY")

>   SPY["2007-01-03"]$SPY.Adjusted > SPY["2007-01-04"]$SPY.Adjusted
     [,1]

If I use as.numeric function it works :

> SPY["2007-01-03"]$SPY.Adjusted > as.numeric(SPY["2007-01-04"]$SPY.Adjusted)
           SPY.Adjusted
2007-01-03        FALSE

> as.numeric(SPY["2007-01-03"]$SPY.Adjusted) > as.numeric(SPY["2007-01-04"]$SPY.Adjusted)
[1] FALSE


Is this the expected behavior ? 


More information about the R-help mailing list