6 data.table
data.table
is Alec’s favorite R package because it is incredibly efficient,
lightweight and has incredibly responsive and dedicated developers (thank you!). dplyr
and
etc tidyverse
packages are full of great functions and workflows, so check those
out as well. Life isn’t about strange, strict binaries/camps - use what works
for you.
Note: if you are having install issues on Mac, check out this reference can be really useful.
6.1 Syntax
DT[i, j, by]
- List columns to store a column of lists, or complex objects within a data.table.
-
.SD
= Subset of the Data.table, .SD vignette - data.table website
- Andrew Brooks - Advanced data.table
6.3 Functions
-
fread
/fwrite
(https://github.com/Rdatatable/data.table/wiki/Convenience-features-of-fread) -
year
,month
,yday
,mday
,hour
,minute
,second
,as.IDate
,as.ITime
-
fcase
: fast case when. When column == value, return x, when column == value2, return x2, etc. -
fifelse
: fast if-else with sensible behaviour