You can use the which.i argument to [.xts: > is.null(SPY["2009-01-18",which.i=TRUE]) [1] TRUE
Best, -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com On Sat, Jan 25, 2014 at 9: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. > [[alternative HTML version deleted]] ______________________________________________ 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.