【问题标题】:countrycode in R - NA's returned when detecting country name in dfR 中的国家代码 - 检测 df 中的国家名称时返回 NA
【发布时间】:2021-10-25 14:56:17
【问题描述】:

我正在尝试为数据框中的国家名称向量获取各个大陆。我正在使用 countrycode 包来执行此操作,但不断将 NA 作为我的目的地返回。我正在使用的示例代码:

country <- data.frame(country = c("Chile", "Argentina", "Poland"))

country %>%
  mutate(continent = countrycode(sourcevar = 'country', origin = 'country.name', destination = 'region'))

如果再次出现这种情况,我深表歉意,但我不确定我在这里做错了什么。

【问题讨论】:

    标签: r country-codes


    【解决方案1】:

    如果这是您所期待的,请告诉我。

    country %>%
      mutate(continent = countrycode(sourcevar = country, origin = 'country.name', destination = 'region'))
    

    【讨论】:

    • 谢谢!现在有道理了:)
    猜你喜欢
    • 2016-06-11
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多