title: remove duplicate rows based on conditions from multiple columns in r
body: <p>I have a data set I would like to remove the rows of data that have duplicate information in 4 different columns.  </p>
  
  <pre><code>foo&lt;- data.frame(g1 = c("1","0","0","1","1"), v1 = c("7","5","4","4","3"), v2 = c("a","b","x","x","e"), y1 = c("y","c","f","f","w"), y2= c("y","y","y","f","c"), y3 = c("y","c","c","f","w"), y4= c("y","y","f","f","c"), y5=c("y","w","f","f","w"), y6=c("y","c","f","f","w"))
  </code></pre>
  
  <p>foo then looks like:</p>
  
  <pre><code>  g1 v1 v2 y1 y2 y3 y4 y5 y6
  1  1  7  a  y  y  y  y  y  y
  2  0  5  b  c  y  c  y  w  c
  3  0  4  x  f  y  c  f  f  f
  4  1  4  x  f  f  f  f  f  f
  5  1  3  e  w  c  w  c  w  w
  </code></pre>
  
  <p>Now, I want to remove any row that has duplicated data based on the Y1-6columns.  So, only row 4 and 1 would be removed if done properly, based on all Y variables being the exact same.  Its a multiple column condition.</p>
  
  <p>I believe I am close, but its just not working correctly.</p>
  
  <p>I have tried: <code>new = foo[!(duplicated(foo[,1:6]))]</code>
  thinking to use the duplicated command that it would search and only find those that matched exactly?</p>
  
  <p>I thought about using a conditional statement with &amp;, but can't figure out how to do that either.<br>
  <code>new = foo[foo$y1==foo$y2|foo$y3|foo$y4|foo$y5|foo$y6]</code></p>
  
  <p>I thought about which but Im now overwhelmed and lost.  I would expect foo to look like:</p>
  
  <pre><code>   g1 v1 v2 y1 y2 y3 y4 y5 y6
  2  0  5  b  c  y  c  y  w  c
  3  0  4  x  f  y  c  f  f  f
  5  1  3  e  w  c  w  c  w  w
  </code></pre>