[R] Help with data.table
François Morneau
francois.morneau at ign.fr
Wed Mar 1 08:56:17 CET 2017
Hello,
Not sure but have you consider using :
expand.grid(E1, E2)
that will create a data.frame of all combinations of your two vectors
and then use it for your search.
Best,
François
Le 01/03/2017 à 08:27, Evan Kransdorf a écrit :
> 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]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list