[R-SIG-Finance] XTS Question

Worik worik.stanton at gmail.com
Wed Jun 2 23:57:34 CEST 2010


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
 >



More information about the R-SIG-Finance mailing list