I have been trying to find a simpler solution to my problem. I have a data set containing many columns:
S.No    A   B   C   D   E   F........N
 1      2   3   2   5   7   9........20
 2      4   3   5   4   4   5........3  
 .
 .
 .
 .
 3000   4   5   6  3  5  3  6 .........2 
I would like to replace the df$C and df$D columns based on the df$A and df$B column values (ordered pairs).
I have this relation in a smaller data frame (df2) where Z and Q correspond to A and B of df. I need to populate C and D values of df based on R and S values of df2.
 Z   Q    R     S
 1   2   0.3    4
 1   3  -0.3   -4 
 2   2  -0.2   -5
 2   3  -0.5   -1
 .
 .
 .
 .
Currently, I am using the brute force for and if loop wherein I am comparing the values from every row in df for columns df$A and df$B with df2$Z and df2$Q and then populating C and D columns of df based on R and S values in df2. Since I have more than a million values, the loops seems to run forever.
Is there a smarter way to do the same ?
