Member-only story
1. Basics:
- Install
data.table
withinstall.packages("data.table")
. - Load
data.table
withlibrary(data.table)
.
2. Creating a Data Table:
- Create a data table using
data.table()
or convert a data frame withas.data.table()
. - Set keys for sorting and indexing with
setkey()
.
3. Data Manipulation:
- Perform fast data manipulation with
:=
for in-place modification. - Use the
by
parameter for grouping operations.
4. Joining:
- Perform fast joins with
data.table
syntax (DT[i, j]
). - Use
on
for non-equi joins.
5. Subset Rows:
- Subset rows with conditions using the
i
argument. - Combine conditions with logical operators (
&
,|
).
6. Subset Columns:
- Subset columns using the
j
argument. - Use column names directly for concise…