title: Aggregate character/string variables
body: <p>I've got a data frame which has a list of Person Reference and then a Trade, each person reference can have multiple trades. I want to aggregate so that it shows the data as below:</p>
  
  <pre><code>Record Person Ref       Trade Code
  1        512       elec, plumbing, gas
  2        654            gas, plumbing
  3        685              elec
  </code></pre>
  
  <p>And so on. </p>
  
  <p>The code I have at the moment is:</p>
  
  <pre><code>TEST&lt;-aggregate(`Trade Code`~`Person Reference`, df, function(test)
        paste(names(table(test)[rank(-1*table(test),ties.method="min")==1],collapse=NULL))
  </code></pre>
  
  <p>Which gives the error:</p>
  
  <pre><code>&gt; Error: unexpected symbol in: "TEST&lt;-aggregate('Trade Code'~'Person
  &gt; Reference', age_arr, function(test)
  &gt; paste(names(table(test)[rank(-1*table(test),ties.method="min")==1],collapse=NULL))
  &gt; View"
  </code></pre>
  
  <p>Can anyone see where I'm going wrong with this?</p>