【问题标题】:Using geocode on a column of addresses - Not recognising them as a location在一列地址上使用地理编码 - 不将它们识别为位置
【发布时间】:2019-03-27 15:21:22
【问题描述】:

我对编码非常陌生,并且有一个数据科学项目将在接下来的两周内完成。当我使用地理编码功能时,Rstudio 不会将名为“AdminPort”的位置列识别为位置。我做错了什么?

# A tibble: 31 x 2
   AdminPort       n
   <fct>       <int>
 1 ABERDEEN       70
 2 AYR            77
 3 BELFAST       187
 4 BRIXHAM       184
 5 BUCKIE         69
 6 CAMPBELTOWN    97
 7 EYEMOUTH       73
 8 FLEETWOOD      92
 9 FRASERBURGH   120
10 GRIMSBY        56
# ... with 21 more rows
geocode(AdminPort, source = "dsk")

【问题讨论】:

    标签: r geocode


    【解决方案1】:

    ggmap 包中的geocode 函数需要一个字符向量作为位置的输入,AdminPort 列是一个因素,您应该在使用geocode 之前将其转换为字符。假设您的数据框称为 df

    df$AdminPort <- as.character(df$AdminPort)
    

    之后你可以使用location=df$AdminPort调用地理编码函数

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-28
      • 1970-01-01
      • 2017-12-26
      • 2012-06-15
      • 2012-07-04
      • 2017-03-23
      • 1970-01-01
      • 2012-05-11
      相关资源
      最近更新 更多