문제

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).

도움이 되었습니까?

해결책

It should always be left to right!

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

[1] 6 7
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top