[R-SIG-Finance] Testing existence in xts

Jeff Ryan jeff.a.ryan at gmail.com
Tue Apr 13 23:25:40 CEST 2010


Try:

> library(xts)
Loading required package: zoo
> x <- xts(1:3, Sys.Date()+1:3)
> x
           [,1]
2010-04-14    1
2010-04-15    2
2010-04-16    3
> x['2010-04-17']
Data:
integer(0)

Index:
integer(0)
> length(x['2010-04-17'])
[1] 0
> length(x['2010-04-16'])
[1] 1
>

HTH
Jeff

On Tue, Apr 13, 2010 at 4:23 PM, Worik Stanton <worik.stanton at gmail.com> wrote:
> How do I test for the existence of an entry in a xts?
>
> Given xts z
>> z
>              z
> 2009-01-08 1.71
> 2009-01-09 1.72
> 2009-01-12 1.71
>
> and I want to test if z["2009-01-10",] exists, how do I do it?
>
> cheers
> Worik
> --
> Dig it out of the ground
> Melt it down
> Bury it
> Guard it
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list