I want to do inner join with the condition that it should give me subtraction of 2 columns.
df1 = data.frame(Term = c(\"T1\",\"T2\",\"T3\"), Sec = c(\
Using data.table
s binary join you can modify columns while joining. nomatch = 0L
makes sure that you are doing an inner join
library(data.table)
setkey(setDT(df2), Sec)
setkey(setDT(df1), Sec)[df2, .(Term, Sec, Value = abs(Value - i.Value)), nomatch = 0L]
# Term Sec Value
# 1: T1 s1 30
# 2: T2 s2 20
# 3: T3 s3 10