Hello! Thank you for your help in advance.
I have two data frames DataBase and Hits
DataBase=
X Y OTDB
0 0 OTDB001
2 14 OTDB002
0 0.5 OTDB003
Hits=
X Y Signal
0 0 100
2.1 14.3 20
7 15 90
Results=
X Y Signal OTDB
0 0 100 OTDB001
0 0 100 OTDB003
2.1 14.3 20 OTDB002
7 15 90 NA
For every X, Y in Hits I want to search the database to see if there is a corresponding value within a threshold of X+/- 0.1 and Y+/- 0.5. If there is a value(s) that matches within the threshold I want to add the OTDB number or "NA" to a new column in a Results data frame. It is likely multiple dataBase entries will match an X,Y from the hits.
For perfect matches of X,Y between Database and Hits I used
Results=merge(DataBase, Hits, by=c("X", "Y"), all.x = TRUE, all.y = TRUE)
However I'm having trouble setting the tolerance in searching. Thank you again for any advice!
Thank you! This works great! I really appreciate your help!! thank you again!