which(is.na(x))

hope this helps. spencer graves

David Andel wrote:
I need to know the position of the NA's in a matrix but it is resisting my approaches.

The problem shows already with a simple vector:


x <- c(TRUE,NA,FALSE,TRUE)
x

[1] TRUE NA FALSE TRUE


which(x)

[1] 1 4


x[x==T]

[1] TRUE NA TRUE


x[x==NA]

[1] NA NA NA NA


x[x=="NA"]

[1] NA


x[x==F]

[1] NA FALSE


How can I get just the position (2) for NA and (3) for FALSE as I do with "which(x)" for TRUE?

Thanks,
David

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to