I have a vector of strings (e.g. country names), and a mapping of those strings to other strings (e.g. a mapping of country names to iso codes).
countries = c('United States', 'Ecuador', 'Russia', 'Russia', 'Ecuador')
mapping = data.frame(country = c('Ecuador', 'Russia', 'United States'),
iso3 = c('ECU', 'RUS', 'USA'))
How can I replace all occurences of country names in countries
by the respective iso codes according to mapping
?