data.table extends R’s native data frame with an extremely fast and memory-efficient syntax built around dt[i, j, by]. It supports in-place column creation and modification with :=, avoiding copies, and is fully compatible with functions that work on data frames.

What’s covered#

  • Basics – data.table(), setDT(), as.data.table()
  • Subset rows using i – row numbers, column values, logical operators
  • Extract and summarize columns with j – .(cols), summary functions
  • Compute and delete columns – := operator, type conversion
  • Group according to by – by, keyby, common grouped operations
  • Chaining – dt[...][...]
  • Functions for data.tables – setorder(), rbind(), cbind(), setnames(), unique(), uniqueN()
  • Apply a function to multiple columns – lapply(.SD, fun) with .SDcols