假设我有一个包含多个位置的矢量(经度和纬度格式。我想使用google_places查找最近的metro_station。但是 我总是收到这样的错误:
“ validateGeocodeLocation(location)中的错误: 位置必须是一对经纬度坐标的向量。
代码在下面给出。
location1 %>% head()
[1] "34.450906, -118.227614" "34.123286, -118.758541" "34.545587, -118.420095" "34.090728, -118.127527"
[5] "34.074736, -118.145959" "34.194489, -118.138263"
这有效
> subway_station <- google_places(location = c(34.407332, -117.911841),
+ rankby = "distance",
+ place_type = "subway_station",
+ key = key)
The radar argument is now deprecated
尝试多次搜索
> subway_station <- google_places(location = location1,
+ rankby = "distance",
+ place_type = "subway_station",
+ key = key)
Error in validateGeocodeLocation(location) :
location must be a vector of a pair of latitude and longitude coordinates
我想可以通过编写循环来解决此问题,但不确定确切的处理方法。非常感谢您的帮助。