title: scaling a subset of columns of data.table in R
body: <p>I would like to <code>scale</code> a subset of columns in my <code>data.table</code>. There are many of these that I would like to <code>scale</code> so i want to avoid specifying them all by name.  The columns that are not being scaled, I would just like to return as is.  Here is what I was hoping would work but it does not:</p>
  
  <pre><code>require(data.table)
  x = data.table(id=1:10, a=sample(1:10,10), b=sample(1:10,10), c=sample(1:10,10))
  &gt; dput(x)
  structure(list(id = 1:10, a = c(1L, 6L, 10L, 7L, 5L, 3L, 2L, 
  4L, 9L, 8L), b = c(4L, 9L, 5L, 7L, 6L, 1L, 8L, 10L, 3L, 2L), 
      c = c(2L, 7L, 5L, 6L, 4L, 1L, 10L, 9L, 8L, 3L)), .Names = c("id", 
  "a", "b", "c"), row.names = c(NA, -10L), class = c("data.table", 
  "data.frame"), .internal.selfref = &lt;pointer: 0x1a85d088&gt;)
  
  sx = x[,c(id, lapply(.SD, function(v) as.vector(scale(v)))), .SDcols = colnames(x)[2:4]]
     Error in eval(expr, envir, enclos) : object 'id' not found
  </code></pre>
  
  <p>Any suggestions?</p>