title: Adding multiple columns to a data.table, where column names are held in a vector
body: <p>I want to add a large number of columns to a data.table in R.
  The column names are held in a vector <code>a</code>. How to do it?</p>
  
  <pre><code>x &lt;- data.table(a=1,b=1)
  f &lt;- function(x) {list(0)}
  </code></pre>
  
  <p>The following works:</p>
  
  <pre><code>x &lt;- x[, c("col1","col2","col3") := f()]
  </code></pre>
  
  <p>but the following doesn't:</p>
  
  <pre><code>a &lt;- c("col1","col2","col3")
  x &lt;- x[, a := f()]
  </code></pre>
  
  <p>How do I add the columns defined within <code>a</code>?</p>