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