I got data like this
structure(list(id = c(1, 1, 2, 2, 2, 3, 3, 3), code2 = c("24600",
"2400", "718", "19C11", "2021", "41C200", "G8511", "2021")), class = "data.frame", row.names = c(NA, -8L))
I want to use the "code" column in the above df2 and scan it through the following df1, and if the code is matching then assign the value from the "score" column in df1
structure(list(code = c("718", "E0012", "G8511", "209BF", "466D",
"2021"), score = c(1, 1, 3, 6, 1, 2)), class = "data.frame", row.names = c(NA, -6L))
and I want the final df to look like this
structure(list(id = c(1, 1, 2, 2, 2, 3, 3, 3), code2 = c("24600",
"2400", "718", "19C11", "2021", "41C200", "G8511", "2021"), score2 = c(NA,
NA, 1, NA, 2, NA, 3, 2)), class = "data.frame", row.names = c(NA, -8L))