title: Merge strings variables across data tables separated by a comma and remove duplicates in R
body: <p>I have multiple dataframes that look like this:</p>
  <pre><code>df.1 &lt;- data.frame(name = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
                     var1 = c(&quot;cat,dog&quot;, &quot;dog,horse,bird&quot;, &quot;eagle,fox,chick&quot;))
  
  df.2 &lt;- data.frame(name = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
                     var2 = c(&quot;cat,dog,worm&quot;, &quot;dog,horse,bird&quot;, &quot;giraffe&quot;))
  
  df.3 &lt;- data.frame(name = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;),
                     var3 = c(&quot;cat,dog,worm&quot;, &quot;dog,horse,bird,cat,lion&quot;, NA))
  ## merged 
  all &lt;- df.1 %&gt;% 
    left_join(df.2) %&gt;% 
    left_join(df.3)
  
  &gt; all
    name            var1           var2                    var3
  1    A         cat,dog   cat,dog,worm            cat,dog,worm
  2    B  dog,horse,bird dog,horse,bird dog,horse,bird,cat,lion
  3    C eagle,fox,chick        giraffe                    &lt;NA&gt;
  </code></pre>
  <p>I would now like to merge vars1 to 3 to get a concise list without duplicates.</p>
  <p>So for example the combined data frame should look like:</p>
  <pre><code>  name                    var1
  1    A            cat,dog,worm
  2    B dog,horse,bird,cat,lion
  3    C eagle,fox,chick,giraffe
  </code></pre>
  <p><code>paste</code> will allow for merging comma separated strings but I am not sure how to remove the duplicates?</p>
  <p>I would like to do this using tidyverse and not another package.</p>