title: Compare Two Columns In A Data Frame And If False Then Capture Value of Another Column
body: <p>I have a data set in which I want to compare two columns. For each row where these column don't match I want to capture the corresponding row value of another value and write it in another data frame.</p>
  
  <p><strong>Input Data</strong></p>
  
  <pre><code>data &lt;- structure(list(A = 1:7, B = c(1L, 2L, 1L, 1L, 1L, 9L, 9L), C = c(1L, 
  3L, 2L, 1L, 6L, 8L, 1L)), class = "data.frame", row.names = c(NA, 
  -7L))
  </code></pre>
  
  <p><strong>Expected Output</strong></p>
  
  <pre><code>  A
  1 2
  2 3
  3 5
  4 6
  5 7
  </code></pre>
  
  <p>Currently I am using following code but this leads to empty rows when the value for <code>B</code> and <code>C</code> column matches in <strong>Input Data</strong>. I want to keep those of <code>A</code> for which <code>B</code> and <code>C</code> don't match.</p>
  
  <p>Is it possible to it any another way so ensure above condition is met?</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>ifelse(data$B == data$C, 
        data$A, "")
  </code></pre>
  
  <p><strong>Output of Above Code</strong></p>
  
  <pre><code>[1] ""  "2" "3" ""  "5" "6" "7"
  </code></pre>