[R-SIG-Finance] Testing existence in xts

Worik Stanton worik.stanton at gmail.com
Wed Apr 14 00:34:05 CEST 2010


So, of course, test the length of the returned value.
> x <- xts(1:3, Sys.Date()+1:3)
> x
           [,1]
2010-04-15    1
2010-04-16    2
2010-04-17    3

I am in a different time zone!

> if(length(x['2010-04-18'])){cat("True\n")}else{ cat("False\n")}
False
> if(length(x['2010-04-17'])){cat("True\n")}else{ cat("False\n")}
True
>

Obvious really.

thank you
Worik


-- 
Dig it out of the ground
Melt it down
Bury it
Guard it



More information about the R-SIG-Finance mailing list