countryname {countrycode}R Documentation

Convert country names in any language to another name or code

Description

Converts long country names in any language to one of many different country code schemes or country names. countryname does 2 passes on the data. First, it tries to detect variations of country names in many languages extracted from the Unicode Common Locale Data Repository. Second, it applies countrycode's English regexes to try to match the remaining cases. Because it does two passes, countryname can sometimes produce ambiguous results, e.g., Saint Martin vs. Saint Martin (French Part). Users who need a "safer" option can use: countrycode(x, "country.name", "country.name") Note that the function works with non-ASCII characters. Please see the Github page for examples.

Usage

countryname(sourcevar, destination = "cldr.short.en", warn = TRUE)

Arguments

sourcevar

Vector which contains the codes or country names to ce converted (character or factor)

destination

Coding scheme of destination (string such as "iso3c" enclosed in quotes ""): type ?codelist for a list of available codes.

warn

Prints unique elements from sourcevar for which no match was found

Examples

## Not run: 
x <- c('Afaganisitani', 'Barbadas', 'Sverige', 'UK')
countryname(x)
countryname(x, destination = 'iso3c')

## End(Not run)


[Package countrycode version 1.3.0 Index]