I'm just trying to wrap my brain around data.tables in R, and I keep coming up empty with anything other than the simplest queries. If I have a data.table call it dtable) with three integer columns each representing dates, d1, d2, and d3 (e.g., 20060415) and want to select a complex subset related to a specific date, this produces the desired result, but results in a vector scan:
dtable[ d1 <= date & (d2 > date | d3 == date) ]
Even if I call setkey(dtable, d1, d2, d3)
I seem to get a vector scan (almost certainly multiple vector scans). In my reading of the documentation, I never saw any examples where selectors in the i/where field were effectively anything but ==.
If I simplify the expression, how can this selection be speeded up using data.table?
dtable[ d1 <= date ]