I'd like to compare the elements a1
in df1
to a2
in df2
and put on element of b1
in b2
. For example, df1[2, 1] == df2[3,1]
then, df2[3,1] <- df1[2,1]
.
set.seed(1)
a1 <- letters
b1 <- rnorm(length(a1))
a2 <- sample(letters, 26, replace = T)
b2 <- rep(0, length(a1))
df1 <- data.frame(a1, b1)
df2 <- data.frame(a2, b2)
OBS.: This question is different of MATCH function in r.
In my question, the data frame df1
presents only one kind of letters, but df2
presents repeated letters.