[datatable-help] How to do binary search on integer key?

Michael Nelson michael.nelson at sydney.edu.au
Fri Mar 8 06:42:00 CET 2013


you just need to wrap the values in `list()` or  `.()


eg

table[list(645)]

table[.(645)]
________________________________
From: datatable-help-bounces at lists.r-forge.r-project.org [datatable-help-bounces at lists.r-forge.r-project.org] on behalf of Yi Yuan [lambandme at gmail.com]
Sent: Friday, 8 March 2013 4:25 PM
To: datatable-help at lists.r-forge.r-project.org
Subject: [datatable-help] How to do binary search on integer key?

Hi, all:
I know someone has asked exactly the same question and there's even an answer. But I think the answer is wrong. Following is the url of that question
http://r.789695.n4.nabble.com/Binary-search-with-integer-key-td3705686.html

so if the key is integer and I would like to select all records where the key=654, how do I do that?
suppose the data table is named table, key variable's name is id

I know you can do it by writing: table[id==645,], but R will conduct vector search this way and is a lot slower than binary search.

So how can I do binary search on integer key??

Thanks!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130308/5d649a48/attachment-0001.html>


More information about the datatable-help mailing list