Hello,

How do I perform a binary search on a data.table with an integer key?

Say I create a data.table with
dt <- data.table(x=11:20, key="x")

Passing the target integer 12 directly to i,
dt[12, ]
results in an error because data.table treats 12 as a row number.

Surrounding 12 in quotes,
dt["12", ]
results in an error because data.table then expects a character key.

The data.frame notation,
dt[x == 12, ]
works, but is slow because data.table appears to be just doing a vector search.

Am I missing something obvious?

Leon
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to