Learn R Programming

countrycode (version 0.2)

countrycode: Countrycode is a utility to convert country coding schemes

Description

Converts long country names into one of seven different coding schemes; translates data 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

countrycode(SOURCEVAR, ORIGIN, DESTINATION)

Arguments

SOURCEVAR
Vector which contains the codes or country names to be converted
ORIGIN
Coding scheme of origin (between quotes "")
DESTINATION
Coding scheme of destination (between quotes "")

Value

  • A vector of converted values of the same length as SOURCEVAR

Details

Supports the following coding schemes: Correlates of War character, CoW-numeric, ISO3-character, ISO3-numeric, ISO2-character, IMF, FIPS 10-4, 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", "country.name". The following strings can be used as arguments for DESTINATION only: "continent", "region"

Examples

Run this code
### Usage example: 
codes.of.origin <- countrycode_data$cowc ## Vector of values to be converted

countrycode(codes.of.origin, "cowc", "iso3c")

### Please note the quotation marks around the 2nd and 3rd args

Run the code above in your browser using DataLab