Use the
:=
operator to add new columns by referenceThis means that the original
data.table
is modified directly, rather than creating a new copyThis means we won’t need to reassign the
data.table
to itself after adding columns (no<-
operator)This makes adding columns very fast, even for large datasets