title: Aggregate data.frame rows using data table with multiple collapse functions
body: <p>I have a large <code>data.frame</code> of this example structure: </p>
  
  <pre><code>df &lt;- data.frame(id = rep(c("a","b","c"),4), sex = rep(c("M","F"),6), score = 1:12)
  </code></pre>
  
  <p>I'd like to efficiently aggregate it by the <code>id</code> column and comma separated paste the unique <code>sex</code> values and keep the maximum <code>score</code> value.</p>
  
  <p>How can I modify this <code>data.table</code> function to achieve that:</p>
  
  <pre><code>setDT(df)[, lapply(.SD, function(x) paste(unique(x), collapse = ",")), by = list(id)]
  </code></pre>