R: Update column based on matching rows from another data frame
问题 I have mydf1 <- data.frame(ID = c(1,2,3,4,5), color = c("red", NA, NA, NA, "green"), name = c("tom", "dick", "harry", "steve", "mike")) mydf2 <- data.frame(ID = c(1,2,99), color = c("red", "orange", "yellow"), name = c("tom", "dick", "Aaron")) I would like to update mydf1$color with the corresponding color from mydf2 for any rows that match on both ID and name. The desired output would be to update the color in row 2 to orange and leave the rest as is: ID color name 1 1 red tom 2 2 orange