[R] Judging if a matrix contains any NA
Steven Yen
syen04 at gmail.com
Mon Jul 27 03:10:34 CEST 2015
How do I judge if a matrix contain any NA or otherwise non-missing,
non-numerical?
In the following, I would like to deliver ONE logical of TRUE or FALSE,
rather than a 4 x 4 matrix containing TRUE or FALSE. Thank you.
> a<-matrix(1:16,nrow=4)
> diag(a)<-NA
> a
[,1] [,2] [,3] [,4]
[1,] NA 5 9 13
[2,] 2 NA 10 14
[3,] 3 7 NA 15
[4,] 4 8 12 NA
> is.na(a)
[,1] [,2] [,3] [,4]
[1,] TRUE FALSE FALSE FALSE
[2,] FALSE TRUE FALSE FALSE
[3,] FALSE FALSE TRUE FALSE
[4,] FALSE FALSE FALSE TRUE
More information about the R-help
mailing list