title: Collapse text by group in data frame
body: <p>How do I aggregate data frame by group in column <code>group</code> and collapse text in column <code>text</code>?</p>
  
  <p>Sample data:</p>
  
  <pre><code>df &lt;- read.table(header=T, text="
  group text
  a a1
  a a2
  a a3
  b b1
  b b2
  c c1
  c c2
  c c3
  ")
  </code></pre>
  
  <p>Required output (data frame):</p>
  
  <pre><code>group text
  a     a1a2a3
  b     b1b2
  c     c1c2c3
  </code></pre>
  
  <p>Now I have:</p>
  
  <pre><code>sapply(unique(df$group), function(x) {
    paste0(df[df$group==x,"text"], collapse='')
  })
  </code></pre>
  
  <p>This works to some extent as it returns text properly collapsed by group, but as a vector:</p>
  
  <pre><code>[1] "a1a2a3" "b1b2"   "c1c2c3"
  </code></pre>
  
  <p>I need a data frame with <code>group</code> column as a result.</p>