title: Conditional sum in R – multiple columns
body: <p>I'm trying to figure out how to extract some specific information from very big tables (e.g., 30'000 rows and 50 columns). </p>
  
  <p>Imagine I have this data frame:</p>
  
  <pre><code>S1 &lt;- c(1,2,1,1,3,1)
  S2 &lt;- c(2,1,3,2,1,1)
  S3 &lt;- c(1,2,2,1,3,1)
  S4 &lt;- c(3,3,4,2,3,1)
  S5 &lt;- c(3,2,5,3,2,2)
  count &lt;- c(10,5,3,1,1,1)
  df &lt;- data.frame(count,S1,S2,S3,S4,S5)
  </code></pre>
  
  <p>What I need is to sum the column "count" when, for instance, S1 and S3 shares the same value (it doesn't matter which value), but no other column has the same value. </p>
  
  <p>In this example, it should returns the value 11, because I should only take into consideration the values of the column "count" from the rows 1 and 4.</p>
  
  <p>In the rows 2, 5 and 6, S1 and S3 have a similar value, but I don't want consider them because there are also other columns with the same value. And finally, not considering row 3 simply because S1 and S3 have different values.</p>
  
  <p>I know how to do it easily in excel, but I was wondering how I could do it in R. I've tried somme commands from dplyr, but I failed.</p>
  
  <p>If any of you could give a help, I'll be very grateful.</p>