[R] Help with data.table

Evan Kransdorf evan.kransdorf at gmail.com
Wed Mar 1 08:27:42 CET 2017


Hello,

I need some help with data.table. I am trying to use data.table to do a
binary search of a large table using 2 keys.

         KEY1 KEY2 PARAM1
row1 1         2        -0.031
row2  2       8         -0.456
row3 3       24        -7.86
row4 5       2          2.89

I set the keys:
#DT<-setkey(DT,KEY1,KEY2)

Then I want to obtain do a binary search using 2 vectors E1 and E2.
#temp<-DT[list(E1,E2),]

When I do this, temp is only for the first-first, second-second,
third-third values of E1 and E2. However, I want the result of a table
search from every combination of values in E1 and E2 (1-1, 1-2, 1-3, 2-1,
2-2, 2-3, 3-1, 3-2, 3-3).

Anyone with any ideas? Thanks very much,

Evan

	[[alternative HTML version deleted]]



More information about the R-help mailing list