I have two different data frames. For example Lets say dataframe 1:
| A |
| -------- |
| 11 |
| 24 |
| 3|
| 14|
| 17|
and dataframe 2:
|b | c |
| -------- | -------------- |
| 23 | Cat |
| 24 | Dog |
| 11 | Cow |
| 3 | Snake |
I want to get c values to dataframe 1. So my desired outcome would be something like that: and dataframe2:
|a | new value|
| -------- | -------------- |
|11 | Cow |
| 24 | Dog |
| 3 | Snake |
| 14 | NA |
| 17 | NA |
I tried this:
library(dplyr)
dataframe1<-dataframe1 %>% mutate(newvalue=ifelse(a%in% dataframe2$b, dataframe2$c,NA))
But this doesnt work properly. What could I do?