I recently noticed in some old code that I had been including extra square brackets when subsetting a data.table and performing a function repeatedly (in my case, calculating correlation matrices). So,# Slow wayrcorr(DT[subgroup][, !'Group', with=F])# Faster wayrcorr(DT[subgroup, !'Group', with=F])(The difference being after subgroup). Just out of curiosity, why does this occur? With the extra brackets, does data.table have to perform some extra computations?
I think this answer should be of some help, in addition to Richard's nice answer.
Absolutely! That was an extremely helpful answer, thanks!
Thanks! I figured something like that was going on.
Chris, it works on the same premise that [ would in base R, if that helps