title: Programmatically assigning columns in data.table with dynamic column names
body: <p>What I'm trying to do is something like this:</p>
  
  <pre><code>DT[,diffs:=c(NA, diff(SPY_mid))]
  </code></pre>
  
  <p>but in a script, without knowing in advance</p>
  
  <pre><code>DT[,diffs:=c(NA, diff(paste('SPY', '_mid', sep='')))]
  </code></pre>
  
  <p>doesn't seem to work. Neither does this:</p>
  
  <pre><code>DT[,'diffs':=c(NA, diff(paste('SPY', '_mid', sep=''))), with=F]
  </code></pre>