Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antarctica has no continent #353

Closed
geryan opened this issue Feb 13, 2024 · 2 comments
Closed

Antarctica has no continent #353

geryan opened this issue Feb 13, 2024 · 2 comments

Comments

@geryan
Copy link

geryan commented Feb 13, 2024

Firstly - thanks to the devs for such a thoroughly useful package amid a clusterfrock of competing definitions.

The definition of continent seems unfit for a lot of purposes - strongly related to #288 - North and South America being together - although I can see the logic in backwards compatibility and going with the existing source, it creates some unexpected behaviours, namely a continent having an NA continent...

countrycode::countrycode(
  sourcevar = "Antarctica",
  origin = "country.name",
  destination = "iso3c"
)
#> [1] "ATA"

countrycode::countrycode(
  sourcevar = "Antarctica",
  origin = "country.name",
  destination = "continent"
)
#> Warning: Some values were not matched unambiguously: Antarctica
#> [1] NA

Would the devs be open to an additional continent definition, if I can find something consistent that would solve the Antarctica issue and #288?

I can see where continent is defined in dictionary/data_regions.csv, though I can't find on gh where that file is used to create codelist. If you can point me in the right direction, I'd be happy to try to implement.

@cjyetman
Copy link
Collaborator

I would strongly suggest using custom_match when you want to use/catch/convert names or codes that are not internally covered by countrycode

countrycode::countrycode(
  sourcevar = "Antarctica",
  origin = "country.name",
  destination = "continent",
  custom_match = c(Antarctica = "Antarctica")
)
#> [1] "Antarctica"

@vincentarelbundock
Copy link
Owner

Thanks for the report!

I agree with @cjyetman that, in general, we should be reluctant to add yet another regional variation, and that a better solution is typically to use the custom_match argument.

That said, our continent code is hosted in a plain CSV, and it does indeed seem to be missing an Antarctica row.

I updated it, and in version 1.5.0.9002 from Github you can now do:

library(countrycode)

countrycode("Antarctica", "country.name", "iso3c")
# [1] "ATA"

countrycode("Antarctica", "country.name", "continent")
# [1] "Antarctica"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants