[R] Compare rows of two matrices

R user R-user at zutt.org
Mon Feb 21 16:14:10 CET 2005


> y <-  matrix( c(20,  NA,  NA,  45,  50,  19,  32, 101,  10,  22,  NA,  NA,  80,  49,  61, 190), ncol=4 )
> x <-  matrix( c(20,  NA,  NA,  NA,  50,  19,  32, 101,  10,  22,  NA,  NA,  80,  49,  61, 190), ncol=4 )
> 
> #Whereas x contains all NA´s from y plus some additional NA´s.
> #I want to find the index of these additional NA´s. I think, there must be a very easy way to do this.


How about this:

  is.na(x) & !is.na(y)


Jonne.




More information about the R-help mailing list