Converts a vector of country names or codes from one system to another returning NA where no match is found.

countryCodeToName(countryCode = NULL)

countryCodeToFIPS(countryCode = NULL)

countryFIPSToName(countryFIPS = NULL)

countryFIPSToCode(countryFIPS = NULL)

countryNameToCode(countryName = NULL)

countryNameToFIPS(countryName = NULL)

Arguments

countryCode

Vector of ISO 3166-1 alpha-2 codes.

countryFIPS

Vector of two-character FIPS codes.

countryName

Vector of English language country names.

Value

A vector of country names or codes.

Examples

library(MazamaSpatialUtils)

# FIPS codes are different!

countryNameToCode("Germany")
#> [1] "DE"
countryNameToFIPS("Germany")
#> [1] "GM"

countryCodeToName("CH")
#> [1] "Switzerland"
countryFIPSToName("CH")
#> [1] "China"

countryCodes <- sample(SimpleCountries$countryCode, 30)

data.frame(
  name = countryCodeToName(countryCodes),
  code = countryCodes,
  FIPS = countryCodeToFIPS(countryCodes)
)
#>                  name code FIPS
#> 1             Ukraine   UA   UP
#> 2             Comoros   KM   CN
#> 3             Romania   RO   RO
#> 4               China   CN   CH
#> 5           Venezuela   VE   VE
#> 6              Israel   IL  -99
#> 7           Greenland   GL   GL
#> 8            Eswatini   SZ   WZ
#> 9         New Zealand   NZ   NZ
#> 10             Malawi   MW   MI
#> 11          Mauritius   MU   MP
#> 12             Guyana   GY   GY
#> 13            Nigeria   NG   NI
#> 14            Ecuador   EC   EC
#> 15            Vanuatu   VU   NH
#> 16      Faroe Islands   FO   FO
#> 17  Trinidad & Tobago   TT   TD
#> 18         Kyrgyzstan   KG   KG
#> 19            Morocco   MA   MO
#> 20        Philippines   PH   RP
#> 21              India   IN   IN
#> 22               Fiji   FJ   FJ
#> 23 Dominican Republic   DO   DR
#> 24           Djibouti   DJ   DJ
#> 25             Serbia   RS   RI
#> 26          Nicaragua   NI   NU
#> 27             Latvia   LV   LG
#> 28     United Kingdom   GB   UK
#> 29       South Africa   ZA   SF
#> 30           Colombia   CO   CO