[datatable-help] matching for both equality and greater than

Steve Harman stvharman at gmail.com
Tue Jul 26 05:42:19 CEST 2011


Hello All,

I have a data table, DT, and two columns, A and B. A has character
values and B has numeric values.
I need to find the rows matching "a" AND greater than or equal to 2.
After setkey(DT,A), I am using DT["a"][B>=2].

However, since this command needs to be repeated many times for many
different values,
I would like it to be as fast as possible.

If I had to test for equality for both variables, then I would use
setkey(DT,A,B) followed by DT[J("A",2)]. However, the second condition
is greater than or equal to, which, results in slower execution
compared to matching for equality for both variables.

I wanted to direct this question to the list to take advantage of any
speed improvement that can be possible and I might be missing. Thank
you very much in advance.

Steve



More information about the datatable-help mailing list