title: If rows has a similar element, keep the shorter row
body: <p>I have a dataframe as shown below. </p>
  
  <p><a href="https://i.stack.imgur.com/qLEUZ.png" rel="nofollow noreferrer">dataframe</a></p>
  
  <p>Data for replication:</p>
  
  <pre><code>x &lt;- data.frame(cluster=c(1,2,3,4,5),
                  groups=c('20000127 20000128',
                           '20000127 20000128 20000134',
                           '20000129 20000130 20000131 20000132',
                           '20000133 20000134 20000135 20000136',
                           '20000128 20000133 20000134 20000135 20000136'),
                  chr=c(17,26,35,35,44), stringsAsFactors=FALSE)
  </code></pre>
  
  <p>I'm trying to come up with a way to analyze the 'group' column for any groups with similar elements and remove the row with the higher count. </p>
  
  <p>For example,
  element 20000128 is present in rows 1,2 &amp; 5. Since row 1 has a lower number of characters, I want to remove rows 2 &amp; 5. I appreciate any help!!</p>
  
  <p>Ideally the end result should only have Cluster 1,3,4. Each element should only appear once. (the clusters with the lowest character count)</p>