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 84 forks source link

Historical ISO code #319

Closed oggioniale closed 1 year ago

oggioniale commented 1 year ago

I'm using countrycode for provide flags and name of countries starting from ISO code. My input contains ISO code about existing countries and some ISO code of countries (e.g. Yugoslavia, YUG, https://www.iso.org/obp/ui/#iso:code:3166:YU) that are no longer there.

Some help about it?

cjyetman commented 1 year ago

As the page you linked to states, YUG is "Transitionally reserved" and therefore not technically part of the current, official specification, so we do not include it in the default iso3c codeset. One way to work around this if your data includes a small list of non-standard codes is to use the custom_match argument...

library(countrycode)
iso3c_codes <- c("DEU", "YUG")

countrycode(iso3c_codes, "iso3c", "country.name.en")
#> Warning in countrycode_convert(sourcevar = sourcevar, origin = origin, destination = dest, : Some values were not matched unambiguously: YUG
#> [1] "Germany" NA

countrycode(iso3c_codes, "iso3c", "country.name.en", 
            custom_match = c(YUG = "Yugoslavia"))
#> [1] "Germany"    "Yugoslavia"
oggioniale commented 1 year ago

thank you ... but in this custom way the countrycode facilities (e.g. translations, flags, etc.) is not usable. Right? Should I manually enter everything for each country not included?

vincentarelbundock commented 1 year ago

Some organizations (ex: "cowc") have official active codes for old historical countries, while others do not (ex: iso2c).

I do not think that the source we use for country flags (cldr Unicode) has a flag for Yugoslavia, but I am not 100% sure.

You may want to look at the raw data files. If the Yugoslavia flag is in that file, we may be able to add it. If it is not, then we won't be able to support it.

https://github.com/vincentarelbundock/countrycode/blob/main/dictionary/get_unicode_symbol.R

vincentarelbundock commented 1 year ago

countrycode ... is not usable. Right? Should I manually enter everything for each country not included?

This feels like hyperbole.

countrycode is software developed and distributed for free, and designed to support the official country designations and symbols of a lot of different organizations. If those organizations do not support a particular (no longer existing country), we provide two easy mechanisms to add codes: custom_match and custom_dict.

vincentarelbundock commented 1 year ago

Closing because this issue is a duplicate of: https://github.com/vincentarelbundock/countrycode/issues/291

cjyetman commented 1 year ago

thank you

... but in this custom way the countrycode facilities (e.g. translations, flags, etc.) is not usable. Right? Should I manually enter everything for each country not included?

If you have an extensive list of custom codes, you can alternatively use the custom_dict argument to pass a fully customizable dictionary.