Question

When applying multiple filters, what is the execution order (left-to-right or right-to-left) for a data.table?

For example,

dt[,!excludeColumns,with=F][date > as.POSIXct('2013-01-02', 'GMT')][is.na(holiday)]

In the above, a data.table is:

  1. being excluded few columns
  2. filtering the rows for certain date-range
  3. filtering the rows for one particular holiday period

Would like to know in which order they get executed? (so that we can put the filter that produces the smallest amount of data first, such that later steps have small data to further operate on, and thus faster).

Was it helpful?

Solution

It should always be left to right!

vec <- 1:10
vec[vec>5][1:2]

[1] 6 7
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top