We can use special symbols, such as .SD, .EACHI, .N, .I, and .BY in data.table, to enhance the functionality. We already saw some examples of .N, which represents the number of rows or the last row.
The .SD symbol holds all columns except the columns in by, and can be used only in the j evaluation part of data.table. The .SDcols symbol is used along with .SD and has columns to be included or excluded in the j part of data.table.
The .EACHI symbol is used in the by grouping to group each subset of the groups in i. This needs a key to be defined. If there is no key, R throws an error.
In the following example, we calculate the maximum salary in each department. If we omit .SDcols="Salary", then R will try to find the max for all ...