countrycode() 不承认科索沃?

Pet*_*Pan 5 r country-codes

我想我在包中发现了一个错误或更确切地说缺少更新countrycode

library(countrycode)
testData <- data.frame(country=c(rep("Germany",3),rep("Kosovo",3)))
testData$iso3 <- countrycode(testData$country, "country.name", "iso3c")
Run Code Online (Sandbox Code Playgroud)

这不仅是出于政治原因,而且因为国际货币基金组织或国际清算银行等国际组织确实将科索沃纳入其数据集,因此存在问题。Countrycode 将NA's在此处生成。

我如何处理这些信息?我认为iso3c应该是KSV。

编辑:我联系了包维护者,他回答说,在科索沃得到正式承认之前,他宁愿保持这种方式。

Kon*_*lph 5

您请求了 ISO 国家代码,而 ISO 根本没有为科索沃分配代码。不过,FIPS 具有:

> countrycode('Kosovo', 'country.name', 'fips104')
[1] "KV"
Run Code Online (Sandbox Code Playgroud)

如果您想要“KSV”作为结果,您可以使用世界银行代码:

> countrycode('Kosovo', 'country.name', 'wb')
[1] "KSV"
Run Code Online (Sandbox Code Playgroud)