I want to check if values (in example below "letters") in 1 dataframe appear in another dataframe. And if that is the case, I want a value (in example below "ranking") which is specific for that value from the first dataframe to be added to the second dataframe... What I have now Is the following:
Df1 <- data.frame (c("A", "C", "E"), c(1:3)))
colnames(Df1) <- c("letters", "ranking")
Df2 <- data.frame (c("A", "B", "C", "D", "E"))
colnames(Df2) <- c("letters")
Df2$rank <- ifelse (Df2$letters %in% Df1$letters,1,0)
However... Instead of getting a '1' when the letters overlap, I want to get the specific 'ranking' number from Df1.
Thanks!
Aucun commentaire:
Enregistrer un commentaire