title: How do you delete a column by name in data.table?
body: <p>To get rid of a column named "foo" in a <code>data.frame</code>, I can do:</p>
  
  <p><code>df &lt;- df[-grep('foo', colnames(df))]</code></p>
  
  <p>However, once <code>df</code> is converted to a <code>data.table</code> object, there is no way to just remove a column.</p>
  
  <p>Example:</p>
  
  <pre><code>df &lt;- data.frame(id = 1:100, foo = rnorm(100))
  df2 &lt;- df[-grep('foo', colnames(df))] # works
  df3 &lt;- data.table(df)
  df3[-grep('foo', colnames(df3))] 
  </code></pre>
  
  <p>But once it is converted to a <code>data.table</code> object, this no longer works. </p>