title: Compare two tables
body: <p>What is the easiest way and the fastest way to compare dataframes.
  Input:</p>
  <pre><code>df1 &lt;- data.frame(ID = c(1, 2, 3, 4),
                    A = c(1, 2, 3, NA),
                    B = c(1, 2, NA, NA))
  &gt; df1
    ID  A  B
  1  1  1  1
  2  2  2  2
  3  3  3 NA
  4  4 NA NA
  
  df2 &lt;- data.frame(ID = c(1, 2, 3, 4),
                    A = c(1, 2, 3, 4),
                    B = c(1, 2, 3, NA))
  &gt; df2
    ID A  B
  1  1 1  1
  2  2 2  2
  3  3 3  3
  4  4 4 NA
  </code></pre>
  <p>I assume that data frames have the same amount of rows and columns.
  The output data frame should contain:</p>
  <ol>
  <li>Column ID with values from df1 or df2 - (doesn't mather if from df1 or df2 because they are the same.</li>
  <li>In columns A and B shoud be value from df2 if content of cell from df1 is different than in df2, or NA if values are the same.</li>
  </ol>
  <p>I can use for and iterate for every row and column but it is not elegant solution.
  Is it better?</p>
  <p>I tried:</p>
  <pre><code>result = apply(ifelse(df1[,] == df2[,], NA, df2[,])
  </code></pre>
  <p>but doesn't work.</p>
  <p>The output df should look like this:</p>
  <pre><code>result &lt;- data.frame(ID = c(1, 2, 3, 4),
                    A = c(NA, NA, NA, 4),
                    B = c(NA, NA, 3, NA)) 
  
  &gt; result
    ID  A  B
  1  1 NA NA
  2  2 NA NA
  3  3 NA  3
  4  4  4 NA
  </code></pre>