data.table is a revolutionary package in R because it uses a new approach to data processing that results in a much faster execution time. However, it has a drawback that it uses a syntax that, although easy to understand, differs considerably from the normal R syntax.
Mainly, every operation in a data table is done inside brackets that normally refer to dimensions in arrays or data frames:
data.table.object[operations over rows, operations over columns, by]
In the preceding code snippet,
by is optional. The columns can be selected either by name or column index. However, for this last option, the
with=FALSE argument has to be added:
> data(iris) > iris <- data.table(iris) > iris[,2,with=F] Sepal.Width 1: 3.5 2: 3.0 3: 3.2 ...