The data.table package
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 ...
Get Learning Shiny now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.