I have a data.table with two of its columns (V1,V2) set as a key. A third column contains multiple values.
I have another data.table with pairs I want to search for in the first table key, and return a united list of the lists in V3.
locations<-data.table(c(-159.58,0.2,345.1),c(21.901,22.221,66.5),list(c(10,20),c(11),c(12,33)))
setkey(locations,V1,V2)
searchfor<-data.table(lon=c(-159.58,345.1,11),lat=c(21.901,66.5,0))
The final result should look like this:
[1] 10 20 12 33
The following works when searching for just one item.
locations[.(-159.58,21.901),V3][[1]]
[1] 10 20
I don't know how to generalize this and use the table "searchfor" as source for the searched indices (BTW - the "searchfor" table can be changed to a different format if it makes the solution easier). Also, how do I unite the different values in V3 I'll then (hopefully) receive, into one list?