What happens if I want to select all the rows in a data.table that do not contain a particular value in the key variable using binary search? By the way, what is the correct
The idiom is this:
DT[-DT["a", which=TRUE]]
x y v
1: b 1 4
2: b 3 5
3: b 6 6
4: c 1 7
5: c 3 8
6: c 6 9
Inspiration from:
Update. New in v1.8.3 is not-join syntax. Farrel's first expectation (!
rather than -
) has been implemented :
DT[-DT["a",which=TRUE,nomatch=0],...] # old idiom
DT[!"a",...] # same result, now preferred.
See the NEWS item for more detailed info and example.