Convert Country Codes

Description

Converts long country names into one of many different coding schemes. Translates from one scheme to another. Converts country name or coding scheme to the official short English country name. Creates a new variable with the name of the continent or region to which each country belongs.

Usage

1
countrycode(sourcevar, origin, destination, warn = FALSE)

Arguments

sourcevar

Vector which contains the codes or country names to be converted

origin

Coding scheme of origin (name enclosed in quotes "")

destination

Coding scheme of destination (name enclosed in quotes "")

warn

Prints unique elements from sourcevar for which no match was found

Note

Supports the following coding schemes: Correlates of War character, CoW-numeric, ISO3-character, ISO3-numeric, ISO2-character, IMF numeric, International Olympic Committee, FIPS 10-4, FAO numeric, United Nations numeric, World Bank character, official English short country names (ISO), continent, region.

The following strings can be used as arguments for origin or destination: "cowc", "cown", "iso3c", "iso3n", "iso2c", "imf", "fips104", "fao", "ioc", "un", "wb", "country.name". The following strings can be used as arguments for destination only: "continent", "region"

Examples

1
2
codes.of.origin <- countrycode::countrycode_data$cowc # Vector of values to be converted
countrycode(codes.of.origin, "cowc", "iso3c")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.