data.tableUsing .SD and .SDcols for the subset of data


Introduction

The special symbol .SD is available in j of DT[i,j,by], capturing the Subset of Data for each by group surviving the filter, i. .SDcols is a helper. Type ?`special-symbols` for the official docs.

Remarks

A reminder: DT[where, select|update|do, by] syntax is used to work with columns of a data.table.

  • The "where" part is the i argument
  • The "select|update|do" part is the j argument

These two arguments are usually passed by position instead of by name.