[R-SIG-Finance] xts question: Extract rows with an NA

Worik worik.stanton at gmail.com
Tue Oct 5 23:56:33 CEST 2010


I wish to extract rows from an xts object that have a NA entry.  I can 
use na.omit to exclude those rows, but I can find no simple way to 
include them.

Is there such a way?

 > X <- xts(cbind(c(1,2,3), c(1,NA,5)), Sys.Date()+1:3)
 > X
            [,1] [,2]
2010-10-07    1    1
2010-10-08    2   NA
2010-10-09    3    5
 > na.omit(X)
            [,1] [,2]
2010-10-07    1    1
2010-10-09    3    5


I want:

 > na.only(X)

            [,1] [,2]
2010-10-08    2   NA


cheers
Worik

-- 
You do not have to be blind to not see what is going on right in front of you if it is behind your back
Pascall West
--



More information about the R-SIG-Finance mailing list