Return a vector of ISO country codes for a given vector of country names.
character vector of country names.
The function includes a preset lookup table of unclean country names, clean country names, and corresponding ISO 3166-1 alpha-2 & alpha-3 codes (2 and 3-letter country codes). Input vectors are first cleaned, which includes removing punctuation and converting to lower-case. Then they are matched to the unclean country names. This step allows for differently-spelled country names to be reconcilled correctly. For example,
"United Kingdom" and
"Great Britain" will both be matched to the same codes.
Output can also be returned as a vector of "clean" country names. In the above example, both names would be matched to
"United Kingdom of Great Britain and Northern Ireland".
If an input value is not in the lookup table, a warning will notify of at which position the unmatched value is, and return the original value in that position in the output.
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.