[R] Find NA in xts object

arun smartpink111 at yahoo.com
Sun Mar 17 02:51:47 CET 2013


HI,
Try this:
 Date1<- seq(as.Date("2012-09-10",format="%Y-%m-%d"),length.out=20,by="day")
set.seed(25)
value<- sample(c(1:5,NA),20,replace=TRUE)
library(xts)
x1<- xts(value,Date1)
colSums(is.na(x1))
#[1] 3
 which(is.na(x1))
#[1]  4  6 13

set.seed(38)
 value2<- sample(c(5:8,NA),20,replace=TRUE)
 x2<- xts(cbind(value,value2),Date1)
colSums(is.na(x2))
# value value2 
 #    3      2 
sapply(x2,function(y) which(is.na(y)))
#$value
#[1]  4  6 13

#$value2
#[1] 10 17
A.K.





----- Original Message -----
From: Pete <freerisk3 at gmail.com>
To: r-help at stat.math.ethz.ch
Cc: 
Sent: Saturday, March 16, 2013 3:25 PM
Subject: [R] Find NA in xts object

Hi to all, i'm new to R

I have an xts object.
Can i find:
a) how many NA are in my object ?
b) eventually where (in which line) they are 

Thank you

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list