Closed NilsEnevoldsen closed 1 year ago
Good catch. I agree with you that the second command should produce NA
.
Thanks a lot for the report. Fixed by commit dbc170281bf6798da1d25a7847d9b69928601bef. The countryname
function gets a new nomatch
argument:
library(countrycode)
x <- c("canada", "antarctica")
countryname(x)
# [1] "Canada" "Antarctica"
countryname(x, destination = "cowc", warn = FALSE)
# [1] "CAN" NA
countryname(x, destination = "cowc", warn = FALSE, nomatch = x)
# [1] "CAN" "antarctica"
Is it intended that
countryname()
returns the country name if the entity exists in the codelist but the destination code isn't valid for that entity? Compare:I don't know what guarantees we make about
countryname()
, but this seems wrong. I would expect anNA
, similar tocountrycode()
.