title: Row operations in data.table using `by = .I`
body: <p>Here is a good SO explanation about <a href="https://stackoverflow.com/questions/21651978/row-operations-in-data-table/37667176">row operations in <code>data.table</code></a></p>
  
  <p>One alternative that came to my mind is to use a unique <code>id</code> for each row and then apply a function using the <code>by</code> argument. Like this:</p>
  
  <pre><code>library(data.table)
  
  dt &lt;- data.table(V0 =LETTERS[c(1,1,2,2,3)],
                   V1=1:5,
                   V2=3:7,
                   V3=5:1)
  
  # create a column with row positions
  dt[, rowpos := .I]
  
  # calculate standard deviation by row
  dt[ ,  sdd := sd(.SD[, -1, with=FALSE]), by = rowpos ] 
  </code></pre>
  
  <p><strong>Questions:</strong> </p>
  
  <ol>
  <li><p>Is there a good reason not to use this approach? perhaps other more efficient alternatives?</p></li>
  <li><p>Why does using <code>by = .I</code> doesn't work the same?</p>
  
  <p><code>dt[ ,  sdd := sd(.SD[, -1, with=FALSE]), by = .I ]</code></p></li>
  </ol>