Supposed I have a vector contains multiple locations(under longitude and latitude format. I want to find the nearest subway_station by using google_places. However I always get the errors like this:
"Error in validateGeocodeLocation(location) : location must be a vector of a pair of latitude and longitude coordinates.
Code is given in the below.
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"
This works
> subway_station <- google_places(location = c(34.407332, -117.911841),
+ rankby = "distance",
+ place_type = "subway_station",
+ key = key)
The radar argument is now deprecated
try with multiple search
> 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
I guess this issue can be fixed by writing loop but not sure what exactly way to do. Many thanks for helping.