If we want to get the top five entries of a column, I guess the canonical approach is:
set.seed(45L)
DT = data.table(A=sample(3, 10, TRUE),
B=sample(letters[1:3], 10, TRUE), C=sample(10))
DT[order(C), C[1:5]]
But I've found in more general scenarios (for example, subsetting on the top five of C then performing some operations on other columns) the following approach to be useful :
However, this approach kills forder detection:
DT[order(C)[1:5], B, verbose = TRUE]
I guess it's easy to detect this and do forder and then subset.