title: Concatenating strings in a column according to values in another column in a dataframe
body: <p>I have a <code>data.frame</code> with two columns of strings as follows.</p>
  
  <pre><code>nos &lt;- c("JM1", "JM2", "JM3", "JM1", "JM5", "JM45", "JM3", "JM45")
  ren &lt;- c("book, vend, spent", "marigold, fortune", "smoke, parchment, smell, book", "mental, past, create", "key, fortune, mask, federal", "tell, warn, slip", "wire, dg333, uv12", "tell, warn, slip, furniture")
  d &lt;- data.frame(nos, ren, stringsAsFactors=FALSE)
  
  d
     nos                           ren
  1  JM1             book, vend, spent
  2  JM2             marigold, fortune
  3  JM3 smoke, parchment, smell, book
  4  JM1          mental, past, create
  5  JM5   key, fortune, mask, federal
  6 JM45              tell, warn, slip
  7  JM3             wire, dg333, uv12
  8 JM45   tell, warn, slip, furniture
  </code></pre>
  
  <p>I want to concatenate the elements of <code>ren</code> column according to the strings in <code>nos</code> column. </p>
  
  <p>For example in the sample data, the elements associated with JM1 which occurs twice should be merged ("book, vend, spent, mental, past, create"). </p>
  
  <p>Also the elements associated with JM45 should be merged keeping only unique words. ("tell, warn, slip, furniture") </p>
  
  <p>The output that I am trying to get is like below.</p>
  
  <pre><code>nos1 &lt;- c("JM1", "JM2", "JM3", "JM5", "JM45")
  ren1 &lt;- c("book, vend, spent, mental, past, create", "marigold, fortune", "smoke, parchment, smell, book, wire, dg333, uv12", "key, fortune, mask, federal", "tell, warn, slip, furniture")
  out &lt;- data.frame(nos1, ren1, stringsAsFactors=FALSE)
  
  out
    nos1                                             ren1
  1  JM1          book, vend, spent, mental, past, create
  2  JM2                                marigold, fortune
  3  JM3 smoke, parchment, smell, book, wire, dg333, uv12
  4  JM5                      key, fortune, mask, federal
  5 JM45                      tell, warn, slip, furniture
  </code></pre>
  
  <p>How to do this in <code>R</code>? My original data set has thousands of such rows in a <code>data.frame</code>.</p>