-
Notifications
You must be signed in to change notification settings - Fork 85
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
"Origin code not supported" error #256
Comments
see 'cow.name' is a "Destination only" code. That being said, that could be made clearer (if not completely removed) in the output of for soe discussion of why it is a destination only code, see for instance #179 |
btw... nice to see |
just to clarify, you should just use "country.name" as origin. It should work. I'm now thinking that this confusion might be encouraged by |
maybe we should issue a warning when names are near the top of candidates. |
true... as I understood it, the original intention was to give likely candidates for an origin code that would cover most/all of a given input vector... that leads me to...
|
Yeah, removing them from the results would probably make sense. Would be nice if we could return "country.name" (and "country.name.de") instead. But I'm off to cook the Joulukinkku now! |
How does providing I thought the function was a sort of universal translator from any name/code into any other. I'm unclear what is gained by adding restrictions to that - but then nor have I been through the full thought process that you guys have.. |
The problem with using a specific long form of country name, is that they are not "standardized". The organizations that publish them do not usually "stand by" them in the same way they do for numeric or alpha code (the unicode org is an exception). So even the Correlates of War organization might spell the DRC differently in different publications. So if even a given vector of names really looks like I've been dealing with these codes for a while now, and IMO the better solution is to always merge based on shorter/standardized numeric or alpha codes. When you call So yeah, this is certainly an opinionated design choice, but I'm quite convinced that it is the right choice. Of course, if you really want to use |
Example:
|
If I understood your question correctly, it works because of a hard-coded switch within the function that changes "country.code" to "country.code.en" if and further, there's a hard-coded switch within the function that sets Lines 82 to 98 in 7454f75
If I remember correctly, the reasoning behind that was...
|
If one would like to do exact matching on one of the name columns of library(countrycode)
cow_names <- na.omit(codelist$cow.name)
from_cow <- countrycode(cow_names, "cow.name", "iso2c", custom_dict = codelist)
#> Warning in countrycode(cow_names, "cow.name", "iso2c", custom_dict = codelist): Some values were not matched unambiguously: Austria-Hungary, Baden, Bavaria, Czechoslovakia, German Democratic Republic, Hanover, Hesse Electoral, Hesse Grand Ducal, Kosovo, Mecklenburg Schwerin, Modena, Parma, Republic of Vietnam, Saxony, Tuscany, Two Sicilies, Wuerttemburg, Yemen Arab Republic, Yemen People's Republic, Yugoslavia, Zanzibar
from_std <- countrycode(cow_names, "country.name", "iso2c")
#> Warning in countrycode(cow_names, "country.name", "iso2c"): Some values were not matched unambiguously: Austria-Hungary, Baden, Bavaria, Czechoslovakia, German Democratic Republic, Hanover, Hesse Electoral, Hesse Grand Ducal, Kosovo, Mecklenburg Schwerin, Modena, Parma, Republic of Vietnam, Saxony, Tuscany, Two Sicilies, Wuerttemburg, Yemen Arab Republic, Yemen People's Republic, Yugoslavia, Zanzibar
identical(from_cow, from_std)
#> [1] TRUE |
Thanks for the explainers @vincentarelbundock @cjyetman. I agree it feels sensible to exlude 'destination' schemes from the guess_field() results. By the way you'd be surprised by how often I use guess_field(). I encounter new unspecified naming/coding systems almost every other day, and this function makes data joins much quicker. But until now I also didn't realise the complexity under the hood of the countrycode function. This is a pretty critical package :) |
Some fields are supported in the default internal dictionary but not others?
The text was updated successfully, but these errors were encountered: