# A tibble: 1 x 9 lon lat type loctype address north south east west <dbl> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> 1 -95.6 29.9 establishment rooftop 9125 west sam houston pkwy n, houston, tx 77064, usa 29.9 29.9 -95.6 -95.6
Does anyone know why is this happening and how can I get a complete list?
The geocode() function is meant for getting coordinates of a specific point; it is not a good use case for obtaining all locations of a particular store.
You could in theory be able to get the data by accessing Google Places API directly (it is a REST API, so it plays nicely with {httr}) but Google is getting all sorts of bad rep recently (to get an idea why do check out their Terms & Conditions). I am not aware of a package wrapper for the API.
I suggest you consider Open Street Map as an data source instead.
Consider this code, built on the excellent {osmdata} package:
library(sf)
library(dplyr)
library(osmdata)
library(leaflet)
# get all types of results / polygons, points, lines as a list
search_res <- opq(bbox = "Houston, TX") %>%
add_osm_feature(key = "name", value = "Kroger") %>%
osmdata_sf()
# select the points returned
kroger_points <- search_res$osm_points %>%
filter(!is.na(name))
# draw a map as a reality check
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addCircleMarkers(data = kroger_points,
fillColor = "red",
stroke = F,
label = ~ name)
Thanks very much for this response, it has been very useful. I just have one follow up question:
Is there a reason why the function does not detect all Kroger? Although it performs almost perfectly, it seems that there are some cases that it couldn't identify.