title: Merge rows containing similar strings using dplyr
body: <p>I have a table containing the following data:</p>
  
  <pre><code>df &lt;- tibble(
    dose = seq(10, 50, 10), 
    date = c("2007-12-15", "2007-10-13","2007-10-13","2007-09-30","2007-09-30"), 
    response = c(45, 67, 66, 54, 55), 
    name = c("Peter,Martin", "Gale,Rebecca", "Rebecca,Gale", "Jonathan,Smith", "Smith,Jonathan")
  )
  </code></pre>
  
  <p>The table:</p>
  
  <pre><code># A tibble: 5 x 4
     dose date       response name          
    &lt;dbl&gt; &lt;chr&gt;         &lt;dbl&gt; &lt;chr&gt;         
  1    10 2007-12-15       45 Peter,Martin  
  2    20 2007-10-13       67 Gale,Rebecca  
  3    30 2007-10-13       66 Rebecca,Gale  
  4    40 2007-09-30       54 Jonathan,Smith
  5    50 2007-09-30       55 Smith,Jonathan
  </code></pre>
  
  <p>One of the columns called <code>name</code> either has a string "FirstName,LastName" or "LastName,FirstName". I wish to merge the rows that contain the same names if they are ordered either way. For example, the rows containing Rebecca,Gale and Gale,Rebecca should merge. </p>
  
  <p>While merging, I wish to get the sums of the columns <code>dose</code> and <code>response</code> and want to keep the first of the <code>date</code> and <code>name</code> entries.</p>
  
  <p><strong>Expected outcome:</strong></p>
  
  <pre><code># A tibble: 3 x 4
     dose date       response name          
    &lt;dbl&gt; &lt;chr&gt;         &lt;dbl&gt; &lt;chr&gt;         
  1    10 2007-12-15       45 Peter,Martin  
  2    50 2007-10-13      133 Gale,Rebecca  
  3    90 2007-09-30      109 Jonathan,Smith
  </code></pre>
  
  <p>Please note that I always want to merge using the <code>name</code> column and not the <code>date</code> column because even if the example contains the same dates, my bigger table has different dates for the same name.</p>