library(countrycode)
# 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'))
x <- c("canada", "antarctica")
countryname(x)
countryname(x, destination = "cowc", warn = FALSE)
countryname(x, destination = "cowc", warn = FALSE, nomatch = x)
Run the code above in your browser using DataLab