!length(SPY["2009-01-18"])
#[1] TRUE

  !length(SPY["2009-01-16"])
#[1] FALSE

#or
 !nrow(SPY["2009-01-16"])

A.K.


On Saturday, January 25, 2014 10:27 AM, ce <zadi...@excite.com> wrote:
Dear all


How to test if xts date exists ? is.null doesn't work.  SPY["2009-01-18"] 
doesn't exist but I can't catch it in my script.

library(quantmod)

getSymbols("SPY")

> SPY["2009-01-16"]
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2009-01-16    85.86    85.99   83.05     85.06  399237200        76.58



> SPY["2009-01-18"]
     SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted


> is.null(SPY["2009-01-18"])
[1] FALSE

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to