title: Comparing Column Values With NA
body: <p>The input table below has data points which are <code>NA</code>. I understand in <code>R</code> when a value is compared with <code>NA</code> it leads to output being <code>NA</code>.</p>
  
  <p>Is there still a way around so that I can still compare using <code>ifelse()</code> and make sure if one of the values being compared is <code>NA</code> then it will still provide output as if <code>NA</code> was a character/string being compared?</p>
  
  <p><strong>Input Raw Data</strong></p>
  
  <pre><code>data &lt;- read.table(header = TRUE, text = "A B
                      NA  TEST
                     TEST TEST
                     Abaxasdas Test")
  </code></pre>
  
  <p><strong>Input Data Table</strong></p>
  
  <pre><code> A       B
  &lt;NA&gt;   TEST
  TEST   TEST
  Abaxasdas Test
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>data$Output &lt;- ifelse(as.character(data$A) == as.character(data$B), "YES", "NO")
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code> A    B   Output
  &lt;NA&gt; TEST  &lt;NA&gt;
  TEST TEST  YES
  Abaxasdas Test NO
  
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code> A    B   Output
  &lt;NA&gt; TEST  NO
  TEST TEST  YES
  Abaxasdas Test NO
  </code></pre>