title: R: Identify non-identical elements in two vectors
body: <p>I have two vectors and I want to know which indices in the vectors are not identical. I am not sure how to do this because <code>NA == NA</code> produces <code>NA</code> and <code>NA == 5</code> also produces <code>NA</code>. Can someone provide guidance?</p>
  
  <pre><code># Create data with NA vs. 3
  dat1 &lt;- data.frame(foo = c(NA, 5, 9),
                    bar = c(3, 5, 9))
  
  # Create data with NA vs. NA
  dat2 &lt;- data.frame(foo = c(NA, 5, 9),
                    bar = c(NA, 5, 9))
  
  # Produces same result
  dat1$foo == dat1$bar
  dat2$foo == dat2$bar
  
  identical((dat1$foo == dat1$bar), (dat2$foo == dat2$bar))
  </code></pre>