R/US_countryConversion.R
countryConversion.Rd
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)
Vector of ISO 3166-1 alpha-2 codes.
Vector of two-character FIPS codes.
Vector of English language country names.
A vector of country names or codes.
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 Trinidad & Tobago TT TD
#> 2 Palestinian Territories PS -99
#> 3 Congo - Brazzaville CG CF
#> 4 Brazil BR BR
#> 5 Philippines PH RP
#> 6 Egypt EG EG
#> 7 Poland PL PL
#> 8 Haiti HT HA
#> 9 Panama PA PM
#> 10 Turkey TR TU
#> 11 Isle of Man IM IM
#> 12 Fiji FJ FJ
#> 13 Netherlands NL NL
#> 14 Peru PE PE
#> 15 Dominica DM DO
#> 16 Georgia GE GG
#> 17 Rwanda RW RW
#> 18 Czechia CZ EZ
#> 19 Sweden SE SW
#> 20 Gabon GA GB
#> 21 Ireland IE EI
#> 22 Congo - Kinshasa CD CG
#> 23 India IN IN
#> 24 Singapore SG SN
#> 25 Greece GR GR
#> 26 Afghanistan AF AF
#> 27 Lebanon LB LE
#> 28 Brunei BN BX
#> 29 Kuwait KW KU
#> 30 Denmark DK DA