I sometimes want to check the number of rows for each value of a variable.  I use the following method.  The first syntax doesn&#39;t work, but the second does.  I think that they ought to give the same result.<div><br></div>

<div><div>&gt; DT &lt;- data.table(x=rep(c(1, 2), each=10), y=1:20)</div></div><div><div>&gt; DT[, length(x), list(x)]</div><div>     x V1</div><div>[1,] 1  1</div><div>[2,] 2  1</div><div>&gt; DT[, length(y), list(x)]</div>

<div>     x V1</div><div>[1,] 1 10</div><div>[2,] 2 10</div></div><div><br></div>