# NOT RUN {
# ISO to Correlates of War
countrycode(c('USA', 'DZA'), origin = 'iso3c', destination = 'cown')
# English to ISO
countrycode('Albania', origin = 'country.name', destination = 'iso3c')
# German to French
countrycode('Albanien', origin = 'country.name.de', destination = 'iso.name.fr')
# Using custom_match to supercede default codes
countrycode(c('United States', 'Algeria'), 'country.name', 'iso3c')
countrycode(c('United States', 'Algeria'), 'country.name', 'iso3c',
custom_match = c('Algeria' = 'ALG'))
# }
# NOT RUN {
# Using `custom_dict` to convert US States names. This dictionary is
hosted on github. We use a shortened URL to load it.
cd <- 'https://bit.ly/2ToSrFv'
cd <- read.csv(cd)
countrycode(c('AL', 'AK'), 'abbreviation', 'state',
custom_dict = cd)
countrycode(c('Alabama', 'North Dakota'), 'state.regex', 'state',
custom_dict = cd, origin_regex = TRUE)
# }
Run the code above in your browser using DataCamp Workspace