假设我有一个向量包含多个位置(在经度和纬度格式下。我想使用 google_places 找到最近的地铁站。但是我总是得到这样的错误:
“ 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
我想这个问题可以通过编写循环来解决,但不确定到底该怎么做。非常感谢您的帮助。