Thanks guys! Apologies for my lack of clarity. ashutoshmits - you're right that the same primary identifier ( TX14566) makes the whole thing more difficult than it should be. Only rows satisfying the distance rule are retained, while others are to be eliminated. Following on from dpryan79 code then, which allows me to know the rows satisfying the rule, I will like to find the means of the two values from the two data frames and get a final output as in the example output above (200+203=202; 723+729=726).
Although got errors after modifying the code:
foo1[which(abs(foo1$V2-foo2$V2) %in% c(3:6)),]
file1[which(abs(file1$V2-file2$V2) %in% c(3:6)),]
errors:
<0 rows> (or 0-length row.names)
Warning message:
In file1 - file2 :
longer object length is not a multiple of shorter object length
Please make it more clear. If two tables can have different number of rows than what should be used as an primary identifier to know which two exact rows should be compared. Here all the rows have the same primary identifier i.e. TX14566. Also, what if the values are not different in the first column of a row but some other column. Do you still want to take the mean or ignore them. What if values differ by more than 6 units in one column and less than 3 in other columns. You will have to come up with clear rules. Take some time and create a good example.