Closed laurapalarz closed 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
.
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
.
(This can be closed now, especially since #336 has been fixed.)
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") )