In this subsection, we focus on the second third of data.table’s square bracket syntax; this is the third responsible for selecting and filtering columns like the SELECT clause in SQL.
Much like we didn’t have to use the name of the data table and the $ operator when selecting and filtering rows, we can just use the bare names of columns in the j section.
Check out the following four lines of code:
> tracks[, trackname] "A Perfect Match" "Mamma Mia" "Upside Down" "Upside Down" "Mamma Mia"> tracks[, .(trackname)] trackname 1: A Perfect Match 2: Mamma Mia 3: Upside Down# ....> tracks[, .(trackname, artist)] trackname artist 1: A Perfect Match A*Teens 2: Mamma Mia A*Teens 3: Upside Down A*Teens> # semantically equivalent ...