Closed vincentarelbundock closed 3 years ago
what's the logic with the destination argument? It finds matches within the first destination code, if NA in the first then use the 2nd, and so forth?
what's the logic with the destination argument? It finds matches within the first destination code, if NA in the first then use the 2nd, and so forth?
Exactly. So, for example, if nomatch="BlahBlah"
, then using a vector as destination
will make no difference between there will be no missing values on second pass.
factory
and crosswalk
seem too generic, so for that reason countrycode_factory
seems the better of the three to me, but I am not expert enough in R to be confident Naming Things.
factory
andcrosswalk
seem too generic, so for that reasoncountrycode_factory
seems the better of the three to me, but I am not expert enough in R to be confident Naming Things.
yeah, that's probably right. Wouldn't want namespace conflicts with other packages, which might happen with such generic names. My main hesitation is that it would be nice to signal that countrycode
is no longer just about countries. I can do arbitrary crosswalks. But I guess I made my bed when calling the package countrycode
.
Alright, since there doesn't seem to be an objection to countrycode_factory
, we'll go with that.
Thanks both!
The other thread is making me rethink this altogether. It's so easy to just wrap countrycode in a function with different defaults that I should probably just scrap this factory idea. Do you agree @cjyetman ?
🤷🏻 wasn't it in response to a specific request/goal? it does have the unique feature of using multiple destination codes in succession, right?
I do think it's probably unnecessary. Personally, I would not use this. I would rather specify arguments explicitly than create a custom function and use that... to me it's easier to read and understand.
I do think it's probably unnecessary. Personally, I would not use this. I would rather specify arguments explicitly than create a custom function and use that... to me it's easier to read and understand.
Ditto.
I suggest adding a section to the documentation for wrapping countrycode with a custom dictionary and/or set defaults.
Thanks both for the thoughtful responses.
I removed the countrycode_factory
function
I kept in the possibility of using a vector for destination
, which allows fallback codes.
I included an example function in the README
I uploaded v1.3.0 to CRAN.
Cheers!
Hi @cjyetman and @NilsEnevoldsen
The next release of
countrycode
will have two new features of note:First, the
destination
argument accepts a vector of arguments. For instance, “SRB” is a valid ISO code but not a valid CoW code, so we get:Second, there is a new “function factory” which can create arbitrary crosswalks or change the defaults of
countrycode
.How should this function be called?
countrycode_factory
factory
crosswalk
Minimal example:
State code example: