title: dplyr split string into a comma separated list
body: <p>I'm trying to use dplyr to split a string into a comma separated string and I'm not having much luck.</p>
  
  <pre><code>dat&lt;-data.frame(key=1:4,labels=c('a','ab','abc','b'))
  </code></pre>
  
  <p>I'm trying to get the labels column to be c('a','a,b','a,b,c','b')</p>
  
  <p>I've tried all of the below variations but nothing seems to work.</p>
  
  <pre><code>dat %&gt;%
    mutate(labels=str_split(labels,''))
  
  dat %&gt;%
    mutate(labels=str_split(labels,'')[[1]])
  
  dat %&gt;%
    mutate(labels=paste(str_split(labels,''),collapse=','))
  </code></pre>