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

Coco (Keeling) Islands #335

Closed laurapalarz closed 1 year ago

laurapalarz commented 1 year ago

Coco (Keeling) Islands appears to be its own continent (in the output I am getting) or, at least, it is not defined in the country-continent conversion data this code relies upon.

Here is the code I'm using to manually make the change. I assume this country should be classified as Oceania.

df2 <- df1 %>% mutate(., continent=countryname(country,destination="continent",warn=FALSE), continent=replace(continent,continent=="Cocos (Keeling) Islands","Oceania") )

NilsEnevoldsen commented 1 year ago

continent is assigned by the World Bank's World Development Indicators. Cocos (Keeling) Islands are not a unit in the WDI, so continent is correctly undefined for it. You can either continue to use a manual override, as you already do, or you can use a different regional classification that does exist for Cocos (Keeling) Islands, such as region or un.region.name.

NilsEnevoldsen commented 1 year ago

On second look, you are running into https://github.com/vincentarelbundock/countrycode/issues/336, which does seem wrong to me. I think the correct behavior would be getting NA rather than Oceania or Cocos (Keeling) Islands.

NilsEnevoldsen commented 1 year ago

(This can be closed now, especially since #336 has been fixed.)