I have 2 data frames df1 and df2 and I want to update df1$Country.Names by df2$Area if the first 4 strings of df1$Country.Names matches with df2$Area, if not they are deleted from df1.
df1$Country.Names <- c("Bahamas the," , "United states", "France","Asia")
df2$Area<- c("Bahamas", "United states of america","United states of america", "France")
The output need should be like this for df1
|Country.Names |
| -------- |
| Bahamas |
| United states of america |
| France|
You can see that "Bahamas the," is updated to "Bahamas" and "United states" is updated to "United states of america", and "France" still look the same but it may or may not need to be changed as for "Asia" it's gone.