title: Extract row indices where duplicated pairs exist and the values of these rows which are different
body: <p>I have the dataframe below:</p>
  
  <pre><code>master &lt;- data.frame(A=c(1,1,2,2,3,3,4,4,5,5), B=c(1,2,3,3,4,5,6,6,7,8),C=c(5,2,5,7,7,5,7,9,7,8),D=c(1,2,5,3,7,5,9,6,7,0))
  </code></pre>
  
  <p>As you can see I have 4 columns <code>A,B,C,D</code>. What I want to achieve is to create a new dataframe which will include the duplicated pair-rows between <code>A</code> and <code>B</code>, the index of rows where this duplication happens and the column names that make those rows different (<code>C,D</code>,or <code>C</code> and <code>D</code>) in a third column. To make my request more clear I display an example with <code>master2</code> instead of <code>master</code> which includes only <code>A</code> and <code>B</code></p>
  
  <pre><code>master2 &lt;- data.frame(A=c(1,1,2,2,3,3,4,4,5,5), B=c(1,2,3,3,4,5,6,6,7,8))
  </code></pre>
  
  <p>and then with:</p>
  
  <pre><code>library(data.table)
  setDT(master2)
  
  master2[master2[, .N, by=names(master2)][ N &gt; 1L ], on=names(master2), 
    .(N, locs = .(.I)), by=.EACHI]
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>#    A B N locs
  # 1: 2 3 2  3,4
  # 2: 4 6 2  7,8
  </code></pre>
  
  <p>So I want this logic implemented to the <code>master</code> dataframe and also add another column named "Different" with the column names that make those rows different. If the rows are identical to everything then the new column with the column names that differ should take as value "nothing".If it is possible to add another column with the initial position of the "Different"column. It will be 3 for C and 4 for D?</p>
  
  <p>The desired output shpuld be something like:</p>
  
  <pre><code># A tibble: 2 x 4
  # Groups:   A [?]
  #     A     B     n locs  different position
  #   &lt;dbl&gt; &lt;dbl&gt; &lt;int&gt; &lt;chr&gt; &lt;chr&gt;    &lt;int&gt;
  #1     2     3     2 3, 4  C, D     3,4
  #2     4     6     2 7, 8  C, D     3,4
  </code></pre>