I have the following vector:
x <- c(3, 7, NA, 4, 8)
And I just want to know the index NAin the vector. If, for example, I wanted to know the index 7, the following code would work:
> which(x == 7)
[1] 2
It seems strange to me that running the same code when trying to find the index NAdoes not give me the desired result.
> which(x == NA)
integer(0)
I also tried the following, but it does not work:
> which(x == "NA")
integer(0)
Your help would be greatly appreciated.
Edit
The question was answered by @ccapizzano, but can anyone explain why the codes above do not work?
source
share