[R] testing if xts date exists ?
    arun 
    smartpink111 at yahoo.com
       
    Sat Jan 25 17:31:37 CET 2014
    
    
  
!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 <zadig_1 at 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 at 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.
    
    
More information about the R-help
mailing list