title: Finding the index of an NA value in a vector
body: <p>I have the following vector:</p>
  
  <pre><code>x &lt;- c(3, 7, NA, 4, 8)
  </code></pre>
  
  <p>And I just want to know the index of the <code>NA</code> in the vector. If, for instance, I wanted to know the index of <code>7</code>, the following code would work:</p>
  
  <pre><code>&gt; which(x == 7)
  [1] 2
  </code></pre>
  
  <p>I find it odd that running the same code when trying to find the index of the <code>NA</code> does not give me the desired result.</p>
  
  <pre><code>&gt; which(x == NA)
  integer(0)
  </code></pre>
  
  <p>I also tried the following but it does not work:</p>
  
  <pre><code>&gt;  which(x == "NA")
  integer(0)
  </code></pre>
  
  <p>Your help will be much appreciated.</p>
  
  <p>Edit</p>
  
  <p>The question has been answered below by @ccapizzano, but can anyone explain why the codes above do not work?</p>