[R-SIG-Finance] XTS Question

Thomas Etheber etheber at gmx.de
Thu Jun 3 08:55:21 CEST 2010


I suppose there are several ways for completing this task, for example:

x[ index(x) != c("1996-01-09", "1996-01-02" ) ]

Hth
Thomas


Am 02.06.2010 23:57, schrieb Worik:
> How do I delete an element from an XTS?
>
> I can jump through hoops with na.omit as below, but there must be a 
> simpler better way that I just cannot see
>
> cheers
> Worik
>
> > dates <- seq.Date(from=as.Date("1996-01-01"), 
> to=as.Date("1996-01-10"), length.out=10)
> > data <- 1:10
> > x <- xts(data, order.by=dates)
> > x
>            [,1]
> 1996-01-01    1
> 1996-01-02    2
> 1996-01-03    3
> 1996-01-04    4
> 1996-01-05    5
> 1996-01-06    6
> 1996-01-07    7
> 1996-01-08    8
> 1996-01-09    9
> 1996-01-10   10
> > x["1996-01-04"] <- NA
> > x <- na.omit(x)
> > x
>            [,1]
> 1996-01-01    1
> 1996-01-02    2
> 1996-01-03    3
> 1996-01-05    5
> 1996-01-06    6
> 1996-01-07    7
> 1996-01-08    8
> 1996-01-09    9
> 1996-01-10   10
> >
>
> _______________________________________________
> 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.
>



More information about the R-SIG-Finance mailing list