The data.table subsetting operator [ follows the pattern DT[i, j, by].
i: The WHERE clause (filtering rows).j: The SELECT or computation clause (calculating values or selecting columns).by: The GROUP BY clause (grouping computations).
Unlike base R data.frame, you do not need to prefix column names with DT$ inside the brackets, and you can use any R expression or function from any package within the j argument.
library(data.table)
DT = as.data.table(iris)
# Syntax: DT[i, j, by]
# Example: Filter rows where Petal.Width > 1.0, calculate mean Petal.Length, grouped by Species
DT[Petal.Width > 1.0, mean(Petal.Length), by = Species]