I\'m looking for a way to do simple aggregates / counts via data.table.
Consider the iris data, which has 50 observations per species. To count the observations per
data.table has a couple of symbols that can be used within the j expression. Notably
.N will give you the number of number of rows in each group.see ?data.table under the details for by
Advanced: When grouping by
byor by i, symbols .SD, .BY and .N may be used in the j expression, defined as follows.....
.N is an integer, length 1, containing the number of rows in the group.
For example:
dt[, .N ,by = Species]
Species N
1: setosa 50
2: versicolor 50
3: virginica 50