With the following data frames. I would like to create a new data frame where quantities for IDs in df2 are updated with the 'Update quantities' values and IDs are replaces with the 'Update_ID' values (which may or may not change from the current ID.
df1 <- data.frame(ID = LETTERS[1:10],Quantity = c(1,2,3,4,5,6,7,8,9,10))
df2 <- data.frame(Cur_ID = c("A","C","D","H"), Update_ID = c("A","C","X","Y"), Update_Quantity = c(20, 21, 22, 23))
desired df3:
ID letters
A 20
B 2
C 21
X 22
E 5
F 6
G 7
Y 23
I 9
J 10
i.e. the quantities for all in df2 are updates, and the IDs if Update_ID is different from Cur_ID.