title: Rounding selected columns of data.table
body: <p>I have following data and code to round selected columns of this data.table:</p>
  <pre><code>mydf = structure(list(vnum1 = c(0.590165705411504, -1.39939534199836, 
  0.720226053660755, -0.253198380120377, -0.783366825121657), vnum2 = c(0.706508400384337, 
  0.526770398486406, 0.863136084517464, 0.838245498016477, 0.556775856064633
  ), vch1 = structure(c(2L, 4L, 1L, 3L, 3L), .Label = c(&quot;A&quot;, &quot;B&quot;, 
  &quot;C&quot;, &quot;E&quot;), class = &quot;factor&quot;)), .Names = c(&quot;vnum1&quot;, &quot;vnum2&quot;, &quot;vch1&quot;
  ), row.names = c(NA, -5L), class = c(&quot;data.table&quot;, &quot;data.frame&quot;
  ))
  </code></pre>
  <pre><code>mydf[,round(.SD,1),]
  </code></pre>
  <blockquote>
  <p>Error in Math.data.frame(list(vnum1 = c(0.590165705411504,
  -1.39939534199836,  :    non-numeric variable in data frame: vch1</p>
  </blockquote>
  <pre><code>cbind(mydf[,3,with=F], mydf[,1:2,with=F][,round(.SD,1),])
  </code></pre>
  <pre><code>   vch1 vnum1 vnum2
  1:    B   0.6   0.7
  2:    E  -1.4   0.5
  3:    A   0.7   0.9
  4:    C  -0.3   0.8
  5:    C  -0.8   0.6
  </code></pre>
  <p>Is there a method with shorter code?</p>