vincentarelbundock / countrycode

R package: Convert country names and country codes. Assigns region descriptors.
https://vincentarelbundock.github.io/countrycode
GNU General Public License v3.0
342 stars 83 forks source link

Countries missing in iso2c #291

Closed lucazav closed 1 year ago

lucazav commented 2 years ago

Canary Islands (IC) and Netherlands Antilles (AN) are missing in iso2c

cjyetman commented 2 years ago

Technically speaking, in iso2c "AN" is "Transitionally reserved" and "IC" is "Exceptionally reserved". {countrycode} only includes "Officially assigned" codes from iso2c because unofficial codes can be (and are) used inconsistently across various data sources. You can see the official list of codes here https://www.iso.org/obp/ui/#search/code/

To deal with data that uses unofficial codes, you can use the custom_match argument of coutnrycode()...

library(countrycode)

countries <- c("Canary Islands", "Netherlands Antilles")
custom_codes <- c("Canary Islands" = "IC", "Netherlands Antilles" = "AN")

countrycode(countries, "country.name", "iso2c", custom_match = custom_codes)
#> [1] "IC" "AN"
vincentarelbundock commented 2 years ago

ISO2c appears to publish an "official" list of:

  1. Officially assigned code elements
  2. Exceptionally reserved code elements
  3. Transitionally reserved code elements
  4. Indeterminately reserved code elements
  5. Formerly assigned code elements
  6. User-assigned code elements

https://www.iso.org/obp/ui/#iso:pub:PUB500001:en

@cjyetman I keep getting requests for this, and at some point there is a "market test". Should we include categories 1, 2, 3 in the dictionary?

NilsEnevoldsen commented 2 years ago

Many of categories 2 and 3 wouldn't apply to countrycode anyway, either because they aren't "countries" or because of 1:1 issues. It would be good to see which codes such a change would actually add.