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

Mrio data #326

Closed christophe-gouel closed 1 year ago

christophe-gouel commented 1 year ago

Following our discussion, here is a first start with the country codes from 2 MRIO: GTAP 10 and Exiobase 3.

I will give more detail in the issue.

vincentarelbundock commented 1 year ago

@christophe-gouel just wanted to say sorry for the delay. I'm super busy at work and don't have time to look at this now. But I'll take a look at this as soon as I find time and energy.

Thanks for your work on this!

christophe-gouel commented 1 year ago

Thanks for the info. It is not urgent at all for me. Take your time.

vincentarelbundock commented 1 year ago

@christophe-gouel I’m very sorry this took so long. Life has been crazy…

I finally merged your great PR. Thanks so much!

I also added a new function called get_dictionary() to make it easier to download custom dictionaries from Github. With the latest development version, you can now do:

library(countrycode)

cd <- get_dictionary("gtap10")
countrycode("Christmas Island", "country.name.en.regex", "gtap.cha", custom_dict = cd)
# [1] "AUS"

cd <- get_dictionary("ch_cantons")
countrycode("ZH", "canton.abb", "canton.name.rm", custom_dict = cd)
# [1] "Turitg"

One thing I’ve noticed is that there are a lot of dupliates in the custom dictionaries you supplied. This means that codes can only work as “destination” codes, but not as “origin” codes. I’ve added regular expressions so that users can always convert long country names to the codes of interest.

Let me know what you think. If everything works well, I’ll release to CRAN very soon.