### LOADING REQUIRED LIBRARIES
# data analysis
library(dplyr) # grammar of data manipulation helping to resolve data manipulation difficulties
library(Hmisc) # useful functions for data analysis and high - level graphics
library(foreign) # read data stored by Minitab, SPSS, Stata
library(openxlsx) # open, read, write,and edit xlsx files
library(tidyverse) # collection of R packages designed for data science
# spatial data analysis
library(leaflet.extras) # to provide extra functionality to the leaflet R package
library(sp) # functions for plotting data as maps, spatial selection, methods for retrieving coordinates
library(sf) # encode spatial vector data
library(maps) # geographic maps
library(tmap) # generate thematic maps
library(spdep) # a collection of functions to create spatial weights matrices from polygon contiguities
library(terra) # methods for spatial data analysis
library(leaflet) # interactive maps
library(mapproj) # map projections
library(mapsapi) #
library(spatialreg) # spatial regression models
library(sfdep) # an interface to 'spdep' to integrate with 'sf' objects and the 'tidyverse
library(tidygeocoder) # makes getting data from geocoding services easy
library(mapboxapi) # 'Mapbox' Navigation APIs, including directions, isochrones, and route optimization.
# visualization
library(ggmap) # spatial data visualization
library(rgeoda) # spatial data analysis based on software GeoDa
library(ggplot2) # Grammar of graphics. System for declarative creating graphics
library(corrplot) # provides a visual exploratory tool on correlation matrix
library(RColorBrewer) # offers several color palettes
library(leafsync) # create small multiples of several leaflet web maps
library(htmltools) # tools for HTML generation and output
# others
library(rlang) # collection of frameworks and APIs for programming with R
library(classInt) # methods for choosing univariate class intervals for mapping or other graphic purposes
library(gridExtra) # to arrange and combine plots for easy comparison
library(knitr) # integrates computing and reporting
### Getting access to distance, reviews, and ratings by using Google Maps
library(tm) # a framework for text mining applications
library(wordcloud) # functionality to create pretty word clouds
library(wordcloud2) #
library(googleway) # provides a mechanism to access various Google Maps APIs, including plotting a Google Map from R and overlaying it with shapes and markers, and retrieving data from the places, directions, roads, distances, geocoding, elevation and timezone APIs
library(gmapsdistance) # allows to calculate distances for a database through Google maps
# library(hereR) # geocode and autocomplete addresses or reverse geocode POIs using the Geocoder API
library(osrm) # enables the computation of routes, trips, isochrones and travel distances matrices (travel time and kilometric distance).
### Text Mining
library(tm) # text mining functions
library(syuzhet) # includes four sentiment dictionaries and provides a method for accessing the robust, but computationally expensive, sentiment extraction tool developed in the NLP group at Stanford.
library(SnowballC)
library(wordcloud)
library(wordcloud2)
library(googleway)
# library(remotes)
# library(openrouteservice)
# remotes::install_github("GIScience/openrouteservice-r")
Mty <- leaflet() %>%
addTiles() %>%
setView(-100.31094, 25.66928, zoom = 14) %>% ### Mty downtown area
addMarkers(-100.31094, 25.66928, popup = "Monterrey Downtown Area")
Mty
#geocodificar el punto de origen Coordenadas de Monterrey
lugar <- google_geocode("Monterrey, Nuevo León, México")
# Extraer latitud y longitud
lat <- lugar$results$geometry$location$lat
lon <- lugar$results$geometry$location$lng
# Ver las coordenadas obtenidas
cat("Latitud:", lat, "Longitud:", lon)
## Latitud: 25.68661 Longitud: -100.3161
### Map coordinates of Parque Fundidora (Starting Point)
latitude <- 25.67885
longitude <- -100.28418
r <- 15000
### Use the google_places function to make a call to the API and save the results
search_str <- google_places(search_string = 'coffee shops', location=c(latitude,longitude), radius=r, key=gmaps_key)
search_str$results
## business_status
## 1 OPERATIONAL
## 2 OPERATIONAL
## 3 OPERATIONAL
## 4 OPERATIONAL
## 5 OPERATIONAL
## 6 OPERATIONAL
## 7 OPERATIONAL
## 8 OPERATIONAL
## 9 OPERATIONAL
## 10 OPERATIONAL
## 11 OPERATIONAL
## 12 OPERATIONAL
## 13 OPERATIONAL
## 14 OPERATIONAL
## 15 OPERATIONAL
## 16 OPERATIONAL
## 17 OPERATIONAL
## 18 OPERATIONAL
## 19 OPERATIONAL
## 20 OPERATIONAL
## formatted_address
## 1 C. Washington 1400, Centro, 64000 Monterrey, N.L., Mexico
## 2 Privadas de Bougambilias, Joyas de Anahuac, 66055 General Escobedo, Nuevo Leon, Mexico
## 3 Lic. Benito Juárez Sur 222, Casco Urbano, 66200 San Pedro Garza García, N.L., Mexico
## 4 Mariano Escobedo 130, Centro, 64000 Monterrey, N.L., Mexico
## 5 Av. Luis Elizondo 325 E, Alta Vista, 64840 Monterrey, N.L., Mexico
## 6 Plaza LR 902, 1a Avenida 903, Vista Hermosa, 64610 Monterrey, N.L., Mexico
## 7 Av. Revolución #3800-Local 210, Torremolinos, 64850 Monterrey, N.L., Mexico
## 8 Río Guadalquivir 433, Del Valle, 66220 San Pedro Garza García, N.L., Mexico
## 9 P.º del Acueducto 6701, 64970 Monterrey, N.L., Mexico
## 10 Av. República Mexicana 420-6, Valle de las Alamedas, 66417 San Nicolás de los Garza, N.L., Mexico
## 11 Calz San Pedro 102, Del Valle, 66220 Monterrey, N.L., Mexico
## 12 Sudamérica 303, Vista Hermosa, 64620 Monterrey, N.L., Mexico
## 13 Av. Anillo Periferico 603, Colinas de San Jerónimo, 64634 Monterrey, N.L., Mexico
## 14 Paseo de los Leones 820-2do sector, Col. Cumbres, 64610 Monterrey, N.L., Mexico
## 15 Río Colorado 255-Local 1, Del Valle, 66220 San Pedro Garza García, N.L., Mexico
## 16 Av. Cto. Frida Kahlo 303, Haciendas de La Sierra, 66278 San Pedro Garza García, N.L., Mexico
## 17 Montes Rocallosos 600-int 105, Residencial San Agustín 2o Sector, 66260 San Pedro Garza García, N.L., Mexico
## 18 Terranova 207, Vista Hermosa, 64610 Monterrey, N.L., Mexico
## 19 Belisario Domínguez 2725-Local 1, Obispado, 64060 Monterrey, N.L., Mexico
## 20 Av. José Vasconcelos 204-12-1, Bosques del Valle 1er Sector, 66250 San Pedro Garza García, N.L., Mexico
## geometry.location.lat geometry.location.lng geometry.viewport.northeast.lat
## 1 25.67310 -100.2999 25.67449
## 2 25.76783 -100.3131 25.76917
## 3 25.66355 -100.4032 25.66487
## 4 25.67631 -100.3105 25.67765
## 5 25.64883 -100.2884 25.65026
## 6 25.69763 -100.3639 25.69891
## 7 25.63777 -100.2734 25.63914
## 8 25.65875 -100.3579 25.66016
## 9 25.59649 -100.2678 25.59779
## 10 25.76901 -100.2714 25.77043
## 11 25.65653 -100.3713 25.65787
## 12 25.68620 -100.3539 25.68757
## 13 25.68373 -100.3726 25.68507
## 14 25.70205 -100.3670 25.70344
## 15 25.65858 -100.3623 25.65985
## 16 25.64597 -100.3220 25.64737
## 17 25.65303 -100.3411 25.65449
## 18 25.69452 -100.3575 25.69577
## 19 25.67481 -100.3507 25.67614
## 20 25.65082 -100.3747 25.65212
## geometry.viewport.northeast.lng geometry.viewport.southwest.lat
## 1 -100.2986 25.67179
## 2 -100.3117 25.76647
## 3 -100.4018 25.66217
## 4 -100.3091 25.67495
## 5 -100.2872 25.64757
## 6 -100.3626 25.69621
## 7 -100.2719 25.63644
## 8 -100.3565 25.65746
## 9 -100.2665 25.59509
## 10 -100.2701 25.76773
## 11 -100.3699 25.65517
## 12 -100.3525 25.68488
## 13 -100.3713 25.68237
## 14 -100.3656 25.70074
## 15 -100.3610 25.65715
## 16 -100.3206 25.64467
## 17 -100.3397 25.65179
## 18 -100.3561 25.69307
## 19 -100.3493 25.67344
## 20 -100.3733 25.64942
## geometry.viewport.southwest.lng
## 1 -100.3013
## 2 -100.3144
## 3 -100.4045
## 4 -100.3118
## 5 -100.2899
## 6 -100.3653
## 7 -100.2746
## 8 -100.3592
## 9 -100.2692
## 10 -100.2728
## 11 -100.3726
## 12 -100.3552
## 13 -100.3740
## 14 -100.3683
## 15 -100.3637
## 16 -100.3233
## 17 -100.3424
## 18 -100.3588
## 19 -100.3520
## 20 -100.3760
## icon
## 1 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 2 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 3 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 4 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 5 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 6 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 7 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png
## 8 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 9 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 10 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 11 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 12 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 13 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 14 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 15 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 16 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 17 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 18 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 19 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## 20 https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/cafe-71.png
## icon_background_color
## 1 #FF9E67
## 2 #FF9E67
## 3 #FF9E67
## 4 #FF9E67
## 5 #FF9E67
## 6 #FF9E67
## 7 #7B9EB0
## 8 #FF9E67
## 9 #FF9E67
## 10 #FF9E67
## 11 #FF9E67
## 12 #FF9E67
## 13 #FF9E67
## 14 #FF9E67
## 15 #FF9E67
## 16 #FF9E67
## 17 #FF9E67
## 18 #FF9E67
## 19 #FF9E67
## 20 #FF9E67
## icon_mask_base_uri
## 1 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 2 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 3 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 4 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 5 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 6 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 7 https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet
## 8 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 9 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 10 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 11 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 12 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 13 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 14 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 15 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 16 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 17 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 18 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 19 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## 20 https://maps.gstatic.com/mapfiles/place_api/icons/v2/cafe_pinlet
## name open_now
## 1 Bendito Café TRUE
## 2 LUMA Coffee Shop TRUE
## 3 Bread Coffee Roasters TRUE
## 4 Coffee Love TRUE
## 5 Kaelum Coffee TRUE
## 6 Rios Coffee Shop TRUE
## 7 Stranger Coffee TRUE
## 8 Sereno Coffee Bar TRUE
## 9 Maravela Coffee & Bakery TRUE
## 10 Eon Time Coffee TRUE
## 11 AMALAY Coffee & Market Plaza Duendes TRUE
## 12 HARINA & OLIVA TRUE
## 13 Local Coffee & Records TRUE
## 14 THE 6AM COFFEE TRUE
## 15 Bikemarket Coffee Shop TRUE
## 16 Kali Coffee Roasters TRUE
## 17 Douma Coffee TRUE
## 18 Recap Coffee TRUE
## 19 montecoyote TRUE
## 20 Café Unamuno TRUE
## photos
## 1 2323, <a href="https://maps.google.com/maps/contrib/112230637144181045197">Daniel Anguiano-Orozco</a>, AeeoHcJQR0C__9iP9pbnfNfYQdAzumI_CVz8z99OXp7N_l8oTkEM--TTOMiSkBaUjtQ8zQupE7LNbXWna9P8cETXaoPraD4SV0BooYgTPkgsFmgc0Pq_FHpBImpQDmeeYAIYHapiwuWQlk_2uj2AdPnHRFXz0CBh4CgLeSEHEXAP9FZ6NstEQUe7pod1-IwQ91yVELIpEB75svMk4gmKLIk2sSeEOp04hubX_6fr8696gyGMv1vDUnF7UrRLsyiHc6G_iXW59qZilYjo_2xZEt0IQxGxdiW9hzz6FtMDjI5NDVY1k6m0Yjo7g5_O_m0EoMpuDIemYDS_etja9Wum53XFXjiwAU4OOvThAbQIQ-9iZtfY0IZQlt59dzpVM4tV3bqzjQWuynvjvbieR55DwSH4QqnshDKNEkX2u7rJdt5AAk10updxFVqGL3v5Y1aX7GNmpKmq_h3mD_kae3vWP7pWblhr4raYi8TZZQTnV3fXk4-deaaDwglBY7_JzrLAHqzTEx8Voak9PBIy3SBM3nQZ2Kur7M9KHtlDUnlb8HJTxDA6XU_s0_0h8KWgvsFIecD8HrQomFWm, 2524
## 2 4032, <a href="https://maps.google.com/maps/contrib/100731198256294926188">Juan Cardenas</a>, AeeoHcKyjO0c-BGEjLUvaVJLpPCNyzSFsKz_1vIpkWdKVtu0kOqMsvuShM4WA_73CGTu0Khm0P6_tuz2tNyoP39zenwwmoUfqwwQd87pz7D75qDfRZrEtjHRHdewlS-vaBv8y8FUMaGRmEjEcv_M_3Ew_VZ1n4u6KmiXSYLwobA1Igt4PqmuCP0V-bfdmAssYKIrM8rSOo_zZ_edDdF4fDiPLqh0OBJbPO43qnFyplXKw_myFGKMfAjmb5xFL4nqcZLZEzQslXTwyhMDKV3Nymt_w5GV04bcv338VqbbPkJY2gB95NOKNMpeytk6sb0maucCbLzuLQmyW0qvda7xLo6Fbw0R6AHm-TYfnuS9Ij1X2hYq9xvHa2Cml2nvF6d3VrsWiBjIMh7Kyjhhzls3a28_TsfSF7L7vIfXZMVKz5o_TVqzSCiNScpQaUQETKMsx2LBunSgwwenfNhQ0WWvd5iY4X5da2DMW1Mlm-0H1m5-a-XTsyfpbR5k87KaxshMHJ9FRFSrohTi7wD0ljK2tPLbsc3qMqmLzJ3CUakBcAtgvBzkzv6KpeutJW7BWcDTOeW1jQbTs3Kn, 3024
## 3 4032, <a href="https://maps.google.com/maps/contrib/113137222977805126569">Rodrigo Romero</a>, AeeoHcJwf3rPJVbHtn9wAKUaubNIT6nb83N07E9R7yhVJmwb62zo4IKVtvOnaS2kKbT2dWG_oruSPaK4pujHh-vusGdqwATIE6YQfn8dcPyH4A8FlAzbznrNbnd9IBNj0JUwVubznmEIn2docV8SG_2jAe0QIItT98XvUTxeVRYcMcY0xxo5FfhENmteK7MHy0n7R-SQXKCyscHeOrCWrEbKRXxNF3Q-Ob5rEQgpZVEETyLat4aSdDDE9D_iiiKYUdyLSwEZqiYV6d05KcGxUJ4kdShVgctTitgGIUV1S8NrJ7Gv546LJr23ft8cHDTHKR496l_au4vK_-HCBQ-Wz6y3-Pg9m4oenFhXJnmA7fZCZAoh1k_xnO8YzDaW4iRXr9MLPPoixQuWGzRvfbMMWR9U_o_-SkgDkooxEY-Av_3xX5hL-B9b-g4qyqAv-t6nZZWwP2xhnZKwA2wTKfU524enEJAB3Znik2OMlmuKESn0gRordiolkZ-DiZovgAnzWHLhn16xRi39UcCsihLIoacNTAqI0sp0fWPPZwGGwsBgvnoFl2dNjRmyLsZl4fnUxhIOO2DrS2lk, 3024
## 4 4032, <a href="https://maps.google.com/maps/contrib/105921765917226443857">Patricia Morales Cavazos</a>, AeeoHcLyTfMLKdXgStrn0sAVRPHBWQoafYh9i6vr4qqjMOS5h6DCPqRM2pcUuJkt_hKmrakwvh1pCn7Jmkf8CrozMt_ZYuApavCxHzozL1sJ7Paw8a6UmOfjMfCqp9HdGV8aYGvRmrQsTManiro1E5coDPhxbxfKEsSP56oK8QP8MY9UbLfWRmpO2EzCq9kOXSxhMDT-3dhn5cB-f9tdauPwI5ytYKX1anaiBLt1Ev0vEwmto4hxsCZOjuLfQw0W2SqYWk7u-quEkB7H6fU4ai2NKWC83AxHXYBDBbVMtwPeHSqNgyaQp9Esy4nvpM9ywODezbm4WhkT8Z8__1h4Ir_Jw0ng5PWXkb0FAEQLcyx0hdPY8nc50a4JjaO0Wk2L90enCKEvGbTCCbn-lhjyMCWu-lB34HnztgdAYsbDiHc3kKuRwoCKrkPSF_fxthfX_NoohkSFn1kw6N2_0xl8mML2zfbh0LD6Fy5cXprTvsusmyjGQ8O8Q3N4BXmWqYg2Qu2m1yWIRxN7FKb3Ym7cq2NT5j69asbUYMAyHDzV9dmoTdenb6a4yCJpDe9UD54PEPOZIZwPzNznCpkVpQ, 2268
## 5 1020, <a href="https://maps.google.com/maps/contrib/102319744788165355219">A Google User</a>, AeeoHcKDCSuf2b8OrstUXLVpQ7RPS6U-BoTHkjT2XeOHlPHwlGN-cCbnjAlG2O7zRHguRGiwD6D65wKnBbvXsx8vdd-X3dpSEcI3RVWSUE7EJTjhNwhhjcIWb8FFYjiqEQs6BX_WOplwyP9ay1XQZkeMdPmNNaQ3YsNB4CSVYlWJ4Nxi2_6oF7mdfBbhjtYMyx5t2Xz96dqvSqjVbc_fKrpcNQa488SAff6ggS8MaRnINFyS21JXCnD-HNVIQ4MJhYrb3Shbojq2mVXuYn2-92qM4P3C4NygwVtnN0c0S9QMKWho2gNqQ28, 680
## 6 1600, <a href="https://maps.google.com/maps/contrib/103940132001747907421">A Google User</a>, AeeoHcKU8u96xOukMCU4yGHey-D4KwpMvZ8-bDwaG36dOpj7T6bzkzvUJ4Kd3jnEZkmDQOycV-dwiM1-5qkn-qK1l8JEuEFq_ds0NZ9a7YjraNquvDkZ8nZFcqX9giXD7gbRVP3yfXXjnuGFmew-ph-G7qqV_ByQzKuYsPfNaCTJvMVE5SMHPjVamcX6dCfbmZ9Iyq_lXi3ZQbVcqjsWVN6s8XFeQmu0BB_hXY_bL4vtTyYNownHQr5Zr9YYJ2kfKhj_cDWSI7aQsrbMnKfU0NV_mIyFzqn_Z9peOa1euxa-yTyKbz3xy3I, 900
## 7 2448, <a href="https://maps.google.com/maps/contrib/106324438655229978232">Victor Manuel Arriaga</a>, AeeoHcIscC0j-HNnT74Kcu5ePVUAHThPpupm9uMc4PJpkC0HnyGRLdJtEFEG8Vn_04vIYQARLIrf9Ra3-neZrupBdEAJIyfYbikgP3nF5NQ2sac7JUiaQ-9AUiW_09WIamuF4I-ARlvJnRhuptBfu3nYhd6ao5YYbZG8-UCFBybb-S_fbO4kk1TSf-RRmLUMdzsCOzr3a_jv6_CTFKandkxt7GiI3Odcinv55S5VpAU7uzCDS9WWe1SaScAAUKY8uv5GpTjtgDjvizbkljN2K6kEiWeU4sH0olfNwWI5TGBzHmpl0qV9yNECIA-uDTdd-i3B8NZ8Q06vkmwLeu4AmIlv6uWJXC9VsptUdpdXRrl3cVqXeA2jTF4FPGpj_AEeqE-junB1-cJfifTrWQYstpSfOF9f1ZT05LsfibUcfOFmjGsaAMvseF1WltqcJXJTd2ECWvpp3z6LBds73kGndoiVjJw_imd0_K1Npaz6d3Rz_LUhUBqoT7QZp_aUUhdMQVU6ydDj8EwkIyulc7M8awbl8QtGv-oE6NLgQgnDaXAH5a2nmw8IA57KfkRqA1ys6g8vuRJDFA, 3264
## 8 4032, <a href="https://maps.google.com/maps/contrib/110456712434682068195">A Google User</a>, AeeoHcLwg8DzeDqjUj4y90vXDDEC7ir9MktpQXX_8gdHjS5Wxz7VgQugO1KkbIgRtvsUZntfoV_AQfY5l3a5V4BwQf-MgESjTtWhVjNKh50rPfe8WVKeiAoevTWCyxCsbxYfZhcSUbx7ZeN5dGrisabVMWXLo4FLwuh_6THJvOw296jFVnVFThvkPU19hPrIenkmv-YVI2sdbul3cfLuTfcwpdW2D6HG6rdu0-3FY0HFnqtldisQT-cXIRLCuoAYpxpoz7pVIZLjg7DIJo2IzIPNH2_mfGdh-Ix5L7h7NaAUhrypzS1v, 3024
## 9 4032, <a href="https://maps.google.com/maps/contrib/117628169769852483961">Valeria Garcia</a>, AeeoHcI0YDtKKZd1SmAH-oY20_ch6065y9wHKJw5-YGyRcgZlh9We4gqV5JOLMMEa8QYbC8BkycUdqr2vPhhnSk88BMuMGQzntlw6VM1yRFssRXpYdiKu3wN01RAit_yXLWx6jjoQOgpHaD9tjyEawve5QJCjYimAJLbUUARLoBY31_Z1tRjFkR8-n_QGb3hbMh7Xx-pXuBjcnQOBlXfw9vgmTGWwoCtQMu2o5Og3dLVq63avFZc5dvXKlyKKxQeuIXwYij5bpyAFFErvb1gck_o4_nwCNduZZvo7i6_PlRKGnGh5DLYc2yKCKdCAW3CT77eOJ31emal3O29kmf0m9CpjeFplFyeAnxytDKfQsQupocUwWC-A0OlKSuF0NLOiZgxsTUPBgGt6MuTFCfYMqb8I54cq5JOQomgmdqZztLWoSRYj6ri_6kmjRbgtWMTQfAu5rpBKEIcs925ZMPNy0PPnpownLl1V5CiagcaHPTN2Kxx_AOggYV6dQlUpBHN2ut9ocroVU7XVief13k1zy-xQHNfv4rvKIn4aQTcfnkAAsw2jLgRV4QvZSqI91LH2DP9uPVV2dFT9oBzqg, 3024
## 10 1600, <a href="https://maps.google.com/maps/contrib/107925514416922214828">A Google User</a>, AeeoHcIqLRU6uYh9Vq2FsZA22BhWYt1M92RaBQk0P4H19_dNnR2Y9dcx7lSkfo1RdxOi_i14_MfewM7KgVh1SJHWARfiuDivl6EEi7YSux566mUKvfQh-M-ahaIJ9jjoTko0fmkXTa_HnUxARWg2qoRN58pk7IfYrCBWu3sgV02qrUClPMi6quWiyMNpjp_JeLA139VhT2bXTIP8HfRbmgNEqrMpK_EQnhVpwa4DLr1NLOcWh_ZEnAoZCIz0iR9_ZWWTfCiYeaT_B6VSMtZtjodoJqm8xTvK8o781NWQBOq4TEhY-xoKYMk, 1200
## 11 3000, <a href="https://maps.google.com/maps/contrib/114140953280193118652">A Google User</a>, AeeoHcLZ3tMTBSzRXWD8NfcXuPuLIT26cpuvxAs0PXYwqEZHAURLBmzD2GbTOtSLg-DdDM6hhMVVuQUr3atXJbXKJaH4hlvSIz7tUH6utu3A4GRjxKJ5t62RDSj2BjqsjFSJiAWUE_0X_X3LhdriIAUeavAY9vic9fQq0XKtoMYsemnrBCaQwzsX8SpAYOnPmWHoOt_b1wB8zEdBetBwScxlMrP2M9B1y1B_tJ4j_LohwXrsLhQXVTk5QXoLaTiRJhO2ZxRfFDDVq2O1GIBYTnkY7N-sY8n6a15M0_K7FoJLnY0rXk1aaxSpZSnaPjGxdk9bd4oYYgWHJ8x27B5-dXQroX-vYC_McLtPOxMo31vRXq9nhztECs__UwAYzfKS5-CDRV7vRTiBFFS1XSpbVLxzBIYQNsjJgNJjgAiUbO7SJx6s8wSZvLIawjGLXVy--2WYYVdxI_dVBRBZCTpR6_7Nr6H6bSw5O4635ihPXZ7hIrbYra98IwgnPnhfyJArAF7sMnPINMJPCAVdOtSoYZo32rql96tF7kdQjPRDkgRGBVVE0E60ZrSEsF-EvhyJDXSw68zzwRe-2UNILw, 4000
## 12 4032, <a href="https://maps.google.com/maps/contrib/105327288987021373170">Dennise M</a>, AeeoHcJx62Wzarm_Lo3IqYG1Vv4ocT6asNmdvWUYgvxlvoNqsV_dxC1xJXFr_EJRTVv53ShbkbGpEj9ksoINq1vF_sxLHHNfv9Mjyn78EFqQxC29V_OKi-mwnfXJC6z2BZJnwee9-gSLodKAlMHKFGNG8OgYxQP8GsfrauaFQYealPNcRN5gqoQPstAx--WbOoPZwMWqCpEqPZnqX3sGa7o3nvfHuaJAVWs_8IJ1z-u09cM2jJT0ZRCaEHyeiQzLv5JOLKKY2e3j1MGJcR8VLq2KHU3FdUYJrCaaODYQ3Oj29X8wbE3QYPU2RPziQ_J6jKIsl9OJxSArFTog_e8Kns-Lh0fkI8bccVB2aPU-TXTTK4qiEB3owk6OUldZQWx31nQeLdASCmzWJyvQAEct24tz4ne_tQl8BbBAhB8pMURv-MAC1KwihgqmU-vD3EfYTXwL0_8A4oC9AGnLGfTojCK0HMkmP-lQelJ6u1DG1uUmQFUPl3R_y_rZcd90eJ2Gs8eLBAHWBizy7HTUFbwagQLfie_z_gIpafKW4h2l_Nuzt24JBdDXnp1k9fpzIRurX0t3RI5c7TyBrqqv2g, 3024
## 13 4032, <a href="https://maps.google.com/maps/contrib/115760882086153535304">A Google User</a>, AeeoHcKezX88D-eF08hcrsEv6i88pgisSoYiMiaaqVqWOG_j_YNsYYgaRenVqofPY0NIfRoa7ETspgHW3p7Z9Z6kIMzKyXi4eVdmCmF8kADwpBhFFq20Ba9cxZkCyuIF0nOrQmHxy2c64UBcgK1wHVwBElBnp0d5MrtKP985eaQXygJ8Y8ReKveKZzWLRJ0CG9yc6bb7Mh0PuCUNNF6eKM-B4kinvjA8mb0cgKfyBOMTEnXt7CvQXtYJUtXZtr_Nm0xCwgkopM7eSSmhR7ljojZ6Y0aFzmap_Bq95xBWKf-qSGKYeSO79lQ, 3024
## 14 4032, <a href="https://maps.google.com/maps/contrib/100575255504576464755">A Google User</a>, AeeoHcJYpdUopHhZoKJuW6DAYhBzdSIFOZzYH36FONb6fP9jcZxVTk2kHdPq7RLHBNTcU7hpBQsp9CJGhibTsoLGimR2mSOBL0Ii_zGR5vHs0h322th2hX98no82MORUa9lFMg9TL6yRBKcy4P15EJYqIqxojOSxvtIH0mtQXwLqRvhPwKQWHPOqLWkQeoD_vNIt1Vc2axFGjdVyoRT4a9r3147XGufwCxMnCsOpZYwEfvvMM-8d6vleUNO3BkwF4ZNd6-4bgwByq1M8sDyOVy2fYetYiVzl9itRdmjDVkdqMqWJNPnWJaydWR4zYM-7lpWKcEUjVUcPVi2lfJlf97FO00HdcLamk2D_hcdBDoNqjvpl3K8ZcQM-guJrvmNgkOcjdcCYs3ovB4JgDwX3Nq3xowP7zFE_Rdqydd86rs-WqrH4SEJv56k7Goh0HEmyL159miUKUToiVNk3GOOLt2fQuSKH-wq8AmdPbxNfTbCaq_6A-Ds0LlQyynvDLqSUwedP-9NGB5naYv0-DEH3Ey-zQnmmbFlWebVNTAEQWCO9xtQ4H0dVBMd9btnAN5u0NaLWLvbIq6M1dHhtyA, 3024
## 15 5184, <a href="https://maps.google.com/maps/contrib/101900672069056477274">A Google User</a>, AeeoHcKxGtVEH8gcHSZcMhzW8UTXqwHikO09b7ccWRmz36wI-1HiXZb3WTvkxAitewrB_OSPkw4b1cHw25R9gyqivcR4ds38T7wygnc-3GasrtrbfWEDcOUZAfcS4p6Djceere70HY2slKLU0g6WOU9r_vWDVVC7EgN7eNsIe4D3WW1cH5BgvvCSccS2C3Ve7PSiL0W_TB-C5tvM2LhPuV7uutJIxYvwA5SghSdzgQa9ahb-NzMFgtdJ-9kE9obeQYd7GD7BCn6BE0WEEsTDRz0fG0V3p8B5oukeaZQr0WOaWy1qF6HQX5U, 2912
## 16 4618, <a href="https://maps.google.com/maps/contrib/117582177553955868876">JAIR LZ</a>, AeeoHcKsttW9PvMtL6QLw9E5I-6GyC6p2tD4n5o8X3bzdAaGFayXTPBEYYf4-ehfD32-I3dOxysa8wThUpj_-O_q375VSvYyUcSbNVy3NhtFXjvQcvA5eu3CWbGBgrSw7ZzbO3E_YXoHJNMhfpT-qoDksAWfoo1gvw8AiC3rFVyaAiXJFXoKfLcI-l4YayoVn-LDEvqLdeSt5CKGZZH06jTfRl5xVP2ELPRViZH7RRuhSaNCUNWZ0zZ4qbUf-5SSgDnMPbz6Myb5uYgbaAKHUI45wFFgUiv8axqaen8NLp9NYtM-KGDOJzPZoGSl4B_3k94Z96_IjSLgI46oBcxVc23O943fLxBQNEg4knbVYH4Ztfn3pVameSVy0ZEtS19mwo-EZuqsbCLJLAogliZNks3Scj_6XzupS5HDTfaHWeQplPywCFqbbv78vAQYnQNL0_dYfIUPrXLUcBxT_GO5hbUmnmstvSkdjpANTd-7Y4AvTBZiyUhOjsSU3fzXqGjzEygOB0uPLi1X5UbiLX_h2nsOrrxLp3no5L54vsUVZrOWvHg_CXQIPiRqx8gNmYIqIJOWHre6WtpQ, 3464
## 17 3024, <a href="https://maps.google.com/maps/contrib/107583409291073614815">A Google User</a>, AeeoHcI6seD9UOYAsporALOoV5PnfYi_XvRv6g0shmOHIk4-Nr9v591sY_LaiN6vH3Zm9w3JNKuLKxGx9nW-9e4OraeyD_IR39JzmmHs7BfBW7DdC5hG8O6cEhIQZNdmkwTGUwakSoGRn3iQvqSUbewpuWaZjefXUDCsecWIBPJQ-N5JMv-hWYh19kAOiX3RjT5gC2e3cLPuJ5Uc8RFIFdi3HGrmcKsdx2Cy2RewPxzgMVahd-C68M768lyVlt7q-GUmGCLVp-O5aZjTfJSMbAVf5-VAVUiaBpI2viITNzEhqxxor4aB510H9cQJNzxf8yE3jNpji29_YXSqiqm8eXrROLHw81q9dITmadSyNSgCoTJ_V8lvouhg0k-k9zEJ1A9-1SXzrTGQcTc9-OhcoWU0wKEEopS400tx36LQffozc_gfisul9ZD-5_hscl3qtYQ_GE2kw80eSIIG4GnW78j2JfU5sNyJxgfZfXl1aVtA46VC9l1dCxA76C_nA_IGH9xHb_71ndniJyMjgm1cDA3FBh5RjFOg-21X8XUKW7wHV1FaIugXvCmnkxDViFdQaFNObRlQIg, 4032
## 18 4032, <a href="https://maps.google.com/maps/contrib/115668661520839738621">A Google User</a>, AeeoHcJsLODfVxP0sMMTwr8yr48sgRJp0o1dGwAzvOP0lQJmpMtNkSEZzjmhteDdoHPqqYmLmkzNvMXtY9S8-hgmWI-d_y0cTPySkMhQgbmw8sVV0Jqvz468BmWdxvlAauahXNrT4Tc5vOGjFjpubt4xtOWhVN-JJ1JYmk6NxecQCegZcts61Ic_5b38IMDpDg-NxFf-vtWC95Rt6-8a9Nf8NB0CdfY5NTbEM9cB6kjDn1FAi6H_zSht6knNTuMURgqhfuTKZwHTYpPQStF6y3_MKW-unqJlK9RIC1-HO4nQTQnbmoGnckIe3AFeb8JPO9gLLpacDZZ_TqfySnbmfsojJDUzSutSxBS55UEjCcCUDYJmdaog8nFYrVfu2AFAD5_EZMVdg_la5p0ooMM9FvXNnrHE7QTZ1w8AIPHVGuq0VJAI5-kGfvZyx_roWIa6H-ik8Wp1m_kkjoOydcWHPWWb5MgtgTyr0pSpRlZ6w5DgCxvbWrChwP3rdRVKMo0xFwv-GanY7ZfOnLWO8ZDvrYA5tDBxTd1Fq6hV0HChK2PXyw6374fzGG-A9cFK3NyMoF_MiIWuh6KBaeLukr3ORQ9tCGsvuW412g, 3024
## 19 3456, <a href="https://maps.google.com/maps/contrib/104516159425127877740">A Google User</a>, AeeoHcInqtWRyIRQTDXHFNYjLpmNDAG8GO2aEHJBVyVI0HoP9L-0km3TXQT6UE7iDcQWi9TKaEN5sPZFQTTT2GZB_FPN_B09nri8PhlUMHUjlHVuudEl1ETHlWbrUulKw5q97hYaQ2ZodSm1oYpCdWVbYF6dYEbivc8Q5X9dGqW21isXpf5SUQLeOZN30SXaAtMKBNpDjycv1BlXUjSTujDiwLVyH_fOC0hNQnVS99nc1csSeYFDJjjCAfDsOb3QpKaYve_o4VwjQkhtf5d4yh6htcdziJElTwETuYyEUlk3SMzVRdWnaOQ, 5079
## 20 1280, <a href="https://maps.google.com/maps/contrib/111840886807385612916">A Google User</a>, AeeoHcJ5V6m-kJTQJ0h3GgLFqyxavyVm8nJyI4zp5blKfZe7fmt7BV1DA-_HeC6rcZhuI9YINu8n5HoMsc7-ssw-vbcM4t2ngdbrW_LkjqPxiAIUij9ORt9NbQMU2jsF2_rOANi48TUlKyKKNQ0Y5A0tJhipSK7ZAvLvXiz6GHboY1rmmNT33RUqj-TehfwsOGAehHprVYwhM0Gi4oKuA1NOfXQ16XwnH1kw27B0CgszFPt0IrMzjeUb7IJSoX0nUV8v1MLtSiytRptx2UKbswiPhDa-oBDv315Tev5P1RIEJNDKF3uOMUU, 960
## place_id plus_code.compound_code
## 1 ChIJC9i4FeO_YoYRRWFDnZo_Ync MPF2+62 Monterrey, Nuevo Leon
## 2 ChIJ0eVTRNOVYoYRaYpQD32D2yQ QM9P+4Q General Escobedo, Nuevo Leon
## 3 ChIJxzkeLgC9YoYRiAaCaPCmnVQ MH7W+CP San Pedro Garza García, Nuevo Leon
## 4 ChIJMWvBVQCVYoYRtPopi9dq_nQ MMGQ+GQ Monterrey, Nuevo Leon
## 5 ChIJyfWpMgC_YoYROZF9Algo9DA JPX6+GJ Monterrey, Nuevo Leon
## 6 ChIJc95aHq6XYoYRnADuK-W66N0 MJXP+2C Monterrey, Nuevo Leon
## 7 ChIJI4j7yMC_YoYRlFBktXQ0kRA JPQG+4J Monterrey, Nuevo Leon
## 8 ChIJ97vb-oG9YoYRkyYjUNhrkBE MJ5R+GV San Pedro Garza García, Nuevo Leon
## 9 ChIJVeCHCgC_YoYR3XL1w39iK6A HPWJ+HV Monterrey, Nuevo Leon
## 10 ChIJvS-MpTCVYoYRE5eUbuAt9Po QP9H+JC San Nicolás de los Garza, Nuevo Leon
## 11 ChIJaWLI94y9YoYRFMx7lsctGqM MJ4H+JF Monterrey, Nuevo Leon
## 12 ChIJSb_21Lu_YoYRPDbv3o3CPv8 MJPW+FF Monterrey, Nuevo Leon
## 13 ChIJxyvGLt2XYoYRysyo2AkmHgU MJMG+FW Monterrey, Nuevo Leon
## 14 ChIJ76Wg_uaXYoYRYzIZoAmLlDU PJ2M+R6 Monterrey, Nuevo Leon
## 15 ChIJY0annRq9YoYRyHja9od3puI MJ5Q+C3 San Pedro Garza García, Nuevo Leon
## 16 ChIJVfpS5ae9YoYRvVPYjTxnFYc JMWH+96 San Pedro Garza García, Nuevo Leon
## 17 ChIJj0bo8_a_YoYRN-sX0WzXwiY MM35+6G San Pedro Garza García, Nuevo Leon
## 18 ChIJpd8v-EGXYoYR_XZsgtOIAk4 MJVV+R2 Monterrey, Nuevo Leon
## 19 ChIJWYxBxTKXYoYRkqoFan5ebHo MJFX+WP Monterrey, Nuevo Leon
## 20 ChIJr1hDNJ69YoYRnZubTAjdk4w MJ2G+84 San Pedro Garza García, Nuevo Leon
## plus_code.global_code rating reference
## 1 75QXMPF2+62 4.2 ChIJC9i4FeO_YoYRRWFDnZo_Ync
## 2 75QXQM9P+4Q 4.8 ChIJ0eVTRNOVYoYRaYpQD32D2yQ
## 3 75QXMH7W+CP 4.9 ChIJxzkeLgC9YoYRiAaCaPCmnVQ
## 4 75QXMMGQ+GQ 4.8 ChIJMWvBVQCVYoYRtPopi9dq_nQ
## 5 75QXJPX6+GJ 4.8 ChIJyfWpMgC_YoYROZF9Algo9DA
## 6 75QXMJXP+2C 4.7 ChIJc95aHq6XYoYRnADuK-W66N0
## 7 75QXJPQG+4J 4.6 ChIJI4j7yMC_YoYRlFBktXQ0kRA
## 8 75QXMJ5R+GV 4.9 ChIJ97vb-oG9YoYRkyYjUNhrkBE
## 9 75QXHPWJ+HV 4.9 ChIJVeCHCgC_YoYR3XL1w39iK6A
## 10 75QXQP9H+JC 4.8 ChIJvS-MpTCVYoYRE5eUbuAt9Po
## 11 75QXMJ4H+JF 4.4 ChIJaWLI94y9YoYRFMx7lsctGqM
## 12 75QXMJPW+FF 4.7 ChIJSb_21Lu_YoYRPDbv3o3CPv8
## 13 75QXMJMG+FW 4.7 ChIJxyvGLt2XYoYRysyo2AkmHgU
## 14 75QXPJ2M+R6 4.9 ChIJ76Wg_uaXYoYRYzIZoAmLlDU
## 15 75QXMJ5Q+C3 5.0 ChIJY0annRq9YoYRyHja9od3puI
## 16 75QXJMWH+96 4.5 ChIJVfpS5ae9YoYRvVPYjTxnFYc
## 17 75QXMM35+6G 4.8 ChIJj0bo8_a_YoYRN-sX0WzXwiY
## 18 75QXMJVV+R2 5.0 ChIJpd8v-EGXYoYR_XZsgtOIAk4
## 19 75QXMJFX+WP 4.6 ChIJWYxBxTKXYoYRkqoFan5ebHo
## 20 75QXMJ2G+84 4.6 ChIJr1hDNJ69YoYRnZubTAjdk4w
## types
## 1 cafe, store, food, point_of_interest, establishment
## 2 cafe, store, food, point_of_interest, establishment
## 3 cafe, store, food, point_of_interest, establishment
## 4 cafe, store, food, point_of_interest, establishment
## 5 cafe, store, food, point_of_interest, establishment
## 6 cafe, store, food, point_of_interest, establishment
## 7 cafe, food, point_of_interest, establishment
## 8 cafe, store, food, point_of_interest, establishment
## 9 cafe, store, food, point_of_interest, establishment
## 10 cafe, store, food, point_of_interest, establishment
## 11 bakery, cafe, store, health, restaurant, food, point_of_interest, establishment
## 12 cafe, store, food, point_of_interest, establishment
## 13 cafe, store, food, point_of_interest, establishment
## 14 cafe, store, food, point_of_interest, establishment
## 15 cafe, store, food, point_of_interest, establishment
## 16 bakery, cafe, store, food, point_of_interest, establishment
## 17 cafe, store, food, point_of_interest, establishment
## 18 cafe, store, food, point_of_interest, establishment
## 19 cafe, store, food, point_of_interest, establishment
## 20 cafe, store, restaurant, food, point_of_interest, establishment
## user_ratings_total price_level
## 1 334 NA
## 2 29 NA
## 3 16 NA
## 4 38 NA
## 5 33 NA
## 6 57 NA
## 7 800 NA
## 8 22 NA
## 9 25 NA
## 10 32 NA
## 11 503 NA
## 12 94 NA
## 13 275 NA
## 14 27 NA
## 15 76 NA
## 16 770 2
## 17 85 NA
## 18 13 NA
## 19 649 NA
## 20 241 NA
### The page_token is the way to tell Google to return the next 20 results in the search instead of only the first 20
search_str_add_one <- google_places(search_string = 'hospitales', location=c(latitude,longitude), radius=r, key=gmaps_key, page_token = search_str$next_page_token)
### The page_token is the way to tell Google to return the next 20 results in the search instead of only the first 40
search_str_add_two <- google_places(search_string = 'hospitales', location=c(latitude,longitude), radius=r, key=gmaps_key, page_token = search_str_add_one$next_page_token)
### The data frame will give you a wealth of information about each place, including its address, latitude & longitude coordinates, price level, star rating, number of ratings, categories, and more.
business_name <- c(search_str$results$name, search_str_add_one$results$name, search_str_add_two$results$name)
business_rating <- c(search_str$results$rating, search_str_add_one$results$rating, search_str_add_two$results$rating)
user_ratings_total <- c(search_str$results$user_ratings_total, search_str_add_one$results$user_ratings_total,search_str_add_two$results$user_ratings_total)
place_id <- c(search_str$results$place_id, search_str_add_one$results$place_id, search_str_add_two$results$place_id)
lat <- c(search_str$results$geometry$location$lat, search_str_add_one$results$geometry$location$lat, search_str_add_two$results$geometry$location$lat)
lon <- c(search_str$results$geometry$location$lng, search_str_add_one$results$geometry$location$lng, search_str_add_two$results$geometry$location$lng)
data <- data.frame(business_name,business_rating,user_ratings_total,place_id,lat,lon)
print(data)
## business_name business_rating
## 1 Bendito Café 4.2
## 2 LUMA Coffee Shop 4.8
## 3 Bread Coffee Roasters 4.9
## 4 Coffee Love 4.8
## 5 Kaelum Coffee 4.8
## 6 Rios Coffee Shop 4.7
## 7 Stranger Coffee 4.6
## 8 Sereno Coffee Bar 4.9
## 9 Maravela Coffee & Bakery 4.9
## 10 Eon Time Coffee 4.8
## 11 AMALAY Coffee & Market Plaza Duendes 4.4
## 12 HARINA & OLIVA 4.7
## 13 Local Coffee & Records 4.7
## 14 THE 6AM COFFEE 4.9
## 15 Bikemarket Coffee Shop 5.0
## 16 Kali Coffee Roasters 4.5
## 17 Douma Coffee 4.8
## 18 Recap Coffee 5.0
## 19 montecoyote 4.6
## 20 Café Unamuno 4.6
## 21 Clínica María Luisa Tecnológico 2.8
## 22 Hospital San José Tecnologico de Monterrey 4.1
## 23 Hospital Monterrey 2004 3.8
## 24 Hospital Nogalar 3.2
## 25 Hospital Cuauhtemoc y Famosa 4.4
## 26 Hospital Regiomontano 3.7
## 27 Ginequito Hospital 3.8
## 28 San Jorge Hospital 4.2
## 29 Hospital del Maestro 5.0
## 30 Hospital General de Zona 33 3.9
## 31 Hospitaria 4.2
## 32 Maternity Clinic and Conchita, Ac 3.7
## 33 Hospital Clinica Nova 4.4
## 34 Doctors Hospital Auna 4.2
## 35 Unidad Medica Santa Lucia 4.4
## 36 Hospital Valle Hebron 4.1
## 37 HOSPITAL CENTRA 2.6
## 38 Saint Leonard Hospital 3.2
## 39 CHRISTUS MUGUERZA Hospital San Nicolás 2.5
## 40 Hospital Sierra Madre 4.0
## user_ratings_total place_id lat lon
## 1 334 ChIJC9i4FeO_YoYRRWFDnZo_Ync 25.67310 -100.2999
## 2 29 ChIJ0eVTRNOVYoYRaYpQD32D2yQ 25.76783 -100.3131
## 3 16 ChIJxzkeLgC9YoYRiAaCaPCmnVQ 25.66355 -100.4032
## 4 38 ChIJMWvBVQCVYoYRtPopi9dq_nQ 25.67631 -100.3105
## 5 33 ChIJyfWpMgC_YoYROZF9Algo9DA 25.64883 -100.2884
## 6 57 ChIJc95aHq6XYoYRnADuK-W66N0 25.69763 -100.3639
## 7 800 ChIJI4j7yMC_YoYRlFBktXQ0kRA 25.63777 -100.2734
## 8 22 ChIJ97vb-oG9YoYRkyYjUNhrkBE 25.65875 -100.3579
## 9 25 ChIJVeCHCgC_YoYR3XL1w39iK6A 25.59649 -100.2678
## 10 32 ChIJvS-MpTCVYoYRE5eUbuAt9Po 25.76901 -100.2714
## 11 503 ChIJaWLI94y9YoYRFMx7lsctGqM 25.65653 -100.3713
## 12 94 ChIJSb_21Lu_YoYRPDbv3o3CPv8 25.68620 -100.3539
## 13 275 ChIJxyvGLt2XYoYRysyo2AkmHgU 25.68373 -100.3726
## 14 27 ChIJ76Wg_uaXYoYRYzIZoAmLlDU 25.70205 -100.3670
## 15 76 ChIJY0annRq9YoYRyHja9od3puI 25.65858 -100.3623
## 16 770 ChIJVfpS5ae9YoYRvVPYjTxnFYc 25.64597 -100.3220
## 17 85 ChIJj0bo8_a_YoYRN-sX0WzXwiY 25.65303 -100.3411
## 18 13 ChIJpd8v-EGXYoYR_XZsgtOIAk4 25.69452 -100.3575
## 19 649 ChIJWYxBxTKXYoYRkqoFan5ebHo 25.67481 -100.3507
## 20 241 ChIJr1hDNJ69YoYRnZubTAjdk4w 25.65082 -100.3747
## 21 111 ChIJM7NijL-_YoYRkgNjbJATN-U 25.65364 -100.2839
## 22 243 ChIJSQSETP69YoYRXHkKtNnwILY 25.66835 -100.3515
## 23 68 ChIJ3aZNrmiVYoYRpxJspkronfs 25.68920 -100.2876
## 24 279 ChIJ-Qv6zzyVYoYRBCXxya3yJLc 25.71183 -100.2789
## 25 74 ChIJS3CkC6KVYoYRgnY6NypqqKk 25.69871 -100.3118
## 26 83 ChIJn3l4_gK-YoYRJ1C25mEVQkY 25.66988 -100.3411
## 27 213 ChIJjxXQv0aUYoYRgd8v8XSqmAA 25.67023 -100.3408
## 28 611 ChIJ_31CuPSVYoYRjiXedZC_160 25.67845 -100.3248
## 29 1 ChIJY7WMCdeVYoYRl04R_QRdpD0 25.70935 -100.3476
## 30 90 ChIJ32mZtNa_YoYROvl44MXpX0M 25.67097 -100.2982
## 31 1099 ChIJmzS9q3-UYoYRh-8CB1pPlDU 25.76665 -100.3079
## 32 284 ChIJi6LdH0HAYoYRinx8OYQxmXE 25.67473 -100.3376
## 33 212 ChIJNbEVU1OVYoYRwq-FWDWX7fw 25.73208 -100.3002
## 34 507 ChIJdUt3Sw-WYoYRcF5ZQlJHSso 25.68467 -100.3563
## 35 12 ChIJ1fFIEaeWYoYRi3QjO5q15eg 25.75029 -100.3516
## 36 40 ChIJH32EAaOWYoYRksOJ-7TjyY4 25.74513 -100.3586
## 37 238 ChIJfVNPEpLBYoYRdRAOWERs0TY 25.65630 -100.1821
## 38 57 ChIJp3Jw-4_tYoYRegHkCUJd42M 25.78545 -100.2432
## 39 301 ChIJTxlKyDKVYoYRgDNOkDYQWVo 25.71867 -100.2423
## 40 104 ChIJ72Smg_-VYoYRZZAiLIEkFzg 25.67344 -100.3473
data_top_ratings <- data %>% slice_max(business_rating, n = 10)
data_low_ratings <- data %>% slice_min(business_rating, n = 10)
# Top 10 por calificación
data_top_ratings <- data %>%
filter(!is.na(business_rating)) %>%
arrange(desc(business_rating), desc(user_ratings_total)) %>%
slice_head(n = 10)
# Bottom 10 por calificación
data_low_ratings <- data %>%
filter(!is.na(business_rating)) %>%
arrange(business_rating, user_ratings_total) %>%
slice_head(n = 10)
# Gráfico: Top 10 por calificación
ggplot(data_top_ratings, aes(x=reorder(business_name, business_rating), y=business_rating)) +
geom_bar(stat="identity", fill="steelblue") +
geom_text(aes(label=round(business_rating,1)), hjust=-0.1, size=3.5) +
labs(title="Top 10 Coffee Shops by Rating", subtitle="Zona Metropolitana de Monterrey", x="", y="Rating") +
coord_flip() +
theme_minimal()
Dentro del área de búsqueda en Monterrey, existe una fuerte competencia, con varios establecimientos logrando la máxima puntuación posible según los usuarios que los han calificado. Una calificación de 4.9 sigue siendo muy buena y coloca a esos negocios entre los mejores encontrados.
# Gráfico: Top 10 por cantidad de reseñas
ggplot(data_top_ratings, aes(x=reorder(business_name, user_ratings_total), y=user_ratings_total)) +
geom_bar(stat="identity", fill="darkseagreen3") +
geom_text(aes(label=user_ratings_total), hjust=-0.1, size=3.5) +
labs(title="Top 10 Coffee Shops by Number of Reviews", subtitle="Zona Metropolitana de Monterrey", x="", y="Reviews") +
coord_flip() +
theme_minimal()
La popularidad midiendose por el numero de reseñas, no siempre se alinea perfectamente con la calificación más alta. Cafetera Mexicana parece ser muy popular o tener más tiempo operando. Negocios con altísima calificación pero pocas reseñas como Fika Coffee Mty podrían ser más nuevos o de nicho. Bikemarket y Wilbertss muestran un buen equilibrio entre alta calificación y un número considerable de opiniones.
# Gráfico: Bottom 10 por rating
ggplot(data_low_ratings, aes(x=reorder(business_name, business_rating), y=business_rating)) +
geom_bar(stat="identity", fill="lightcoral") +
geom_text(aes(label=round(business_rating,1)), hjust=-0.1, size=3.5) +
labs(title="Lowest Rated Coffee Shops", subtitle="Zona Metropolitana de Monterrey", x="", y="Rating") +
coord_flip() +
theme_minimal()
Es interesante notar que incluso los peor calificados tienen calificaciones superiores a 4.0, lo cual se considera bueno. Esto podría indicar que la zona de búsqueda tiene una alta concentración de buenos cafés. Sin embargo, dentro del conjunto de datos, estos son los que tienen un desempeño relativamente inferior según las calificaciones de los usuarios.
### Where in ZMM are located the coffee shops characterized by the highest ratings?
ggmap(get_googlemap(center = c(lon = longitude, lat = latitude), zoom = 13)) +
stat_density2d(data = data_top_ratings, aes(lon, lat, fill = after_stat(level)),
geom = "polygon", alpha = 0.40) +
scale_fill_gradient(low = "green", high = "red", guide = "none") +
labs(x = '', y = '', title = "Heatmap of Top-Rated Coffee Shops",
subtitle = "Zona Metropolitana de Monterrey")
Los cafes con mejores calificaciones se ven agrupados en el centro de monterrey, esta es una zona que se caracteriza con mucha actividad turistica y alto trafico peatonal. Esto sugiere que una ubicación central y concurrida es propicia para cafés de alta calificación. Al igual se ve otra zona de concentración, que parece ser por la zona del TEC, la presencia de una gran población estudiantil, profesores y la ente que vive a su alrededor, genera una demanda constante y concentrada. Esto se debe a que pueden buscar espacios para estudiar o trabajar, que tengan wifi y enchufes, donde vendan alimentos, etc. Los negocios que logran satisfacer las necesidades de este ecosistema tienden a ser muy bien valorados, explicando la formación de este segundo “hotspot” de excelencia cafetera en el sur de la ciudad.
### Where in ZMM are located the coffee shops characterized by the lowest ratings?
ggmap(get_googlemap(center = c(lon = longitude, lat = latitude), zoom = 13)) +
stat_density2d(data = data_low_ratings, aes(lon, lat, fill = after_stat(level)),
geom = "polygon", alpha = 0.42) +
scale_fill_gradient(low = "green", high = "red", guide = "none") +
labs(x = '', y = '', title = "Coffee Shops with the Lowest Ratings", subtitle = "Zona Metropolitana de Monterrey")
## ℹ <https://maps.googleapis.com/maps/api/staticmap?center=25.67885,-100.28418&zoom=13&size=640x640&scale=2&maptype=terrain&key=xxx-TzTcERfzJ3o>
## Warning: Removed 4 rows containing non-finite outside the scale range
## (`stat_density2d()`).
Este mapa muestra la concentración de los cafés con las calificaciones más bajas, los cuales estan ubicados en el are central de monterrey, pudiendo ser junto al parque fundidra. Esto no significa que sean malos, si no que como se vio anteriormente, son buenos pero con reseñas mas bajas. Las mismas características que la hacen una zona atractiva pueden llevar a mayores expectativas de los clientes o mayor competencia.
## request more details about the hospitals using google_place_details()
reviews_top_ratings <- google_place_details(place_id = data_top_ratings$place_id[10], key = gmaps_key)
reviews_low_ratings <- google_place_details(place_id = data_low_ratings$place_id[10], key = gmaps_key)
reviews_top_ratings$result$reviews$text
## [1] "Delicious caramel latte, very good balance of coffee flavor with the sweetness of caramel, you don't need to add sugar, the place is spacious and quiet, ideal for chatting and hanging out, I arrived at 8 (they close at 8:30) and the barista was very friendly, I will visit soon with more time to try the chilaquiles and more coffee!!! ⭐️"
## [2] "Very friendly, delicious coffee and nice place. I plan to return soon"
## [3] "I loved it, it is a very quiet place to work, they have a variety of very delicious foods, the service is incredible"
## [4] "Very nice place, service and very delicious coffee, the Cajeta Latte my favorite"
## [5] "The place is very spacious, it has tables for those who come with a lot of people. They also have plugs and internet to do homework or study. The chilaquiles were very good, as was the frozen mocha."
reviews_low_ratings$result$reviews$text
## [1] "Service is lots better. Instalations have improved"
## [2] "Sin info"
## [3] "They don't admit you on holidays because they leave you there until it's a business day. Being a health institution, it is supposed to have the personnel to cover these days.\nI'm not going to get sick on holidays because there is no staff."
## [4] "Very good care from the residents, nurses and specialist doctors in the pediatric area on the 3rd floor. My son was hospitalized, sadly it was on Children's Day, however, the hospital treated him in the best way, gave them gifts and encouraged them to enjoy even that day. I am also very grateful for the treatments he received so that he could be discharged as soon as possible. The medical staff was always willing to help us and ensure that my baby will recover as soon as possible."
## [5] "All those who give good reviews must be employees, they didn't let me pass because I brought 1 jar of ground coffee in my work suitcase and I'm only going for an appointment!!!\nThey tell me to read the guidelines that are on the door to which I comment that there it only says food to the px and she tells me whatever, leave it there and after a while you pick it up to which I ask her if she is responsible for ensuring that no one takes my things or introduces something and she tells me (obviously) no! All of this in a very bad way and almost yelling at me in front of everyone."
### Generate a vector containing only the text
top_ratings_text <- reviews_top_ratings$result$reviews$text
top_ratings_doc <- Corpus(VectorSource(top_ratings_text))
low_ratings_text <- reviews_low_ratings$result$reviews$text
low_ratings_doc <- Corpus(VectorSource(low_ratings_text))
### Clean the text data
options(warn=-1)
top_ratings_doc <- top_ratings_doc %>% tm_map(removeNumbers) %>% tm_map(removePunctuation) %>% tm_map(stripWhitespace)
top_ratings_doc <- tm_map(top_ratings_doc, content_transformer(tolower))
top_ratings_doc <- tm_map(top_ratings_doc, removeWords, stopwords("english"))
options(warn=-1)
low_ratings_doc <- low_ratings_doc %>% tm_map(removeNumbers) %>% tm_map(removePunctuation) %>% tm_map(stripWhitespace)
low_ratings_doc <- tm_map(low_ratings_doc, content_transformer(tolower))
low_ratings_doc <- tm_map(low_ratings_doc, removeWords, stopwords("english"))
### Lets create a dataframe containing each word in the first column and their frequency in the second column.
options(warn=-1)
dtm_top <- TermDocumentMatrix(top_ratings_doc)
matrix_top <- as.matrix(dtm_top)
words_top <- sort(rowSums(matrix_top),decreasing=TRUE)
words_top_df <- data.frame(word = names(words_top),freq=words_top)
options(warn=-1)
dtm_low <- TermDocumentMatrix(low_ratings_doc)
matrix_low <- as.matrix(dtm_low)
words_low <- sort(rowSums(matrix_low),decreasing=TRUE)
words_low_df <- data.frame(word = names(words_low),freq=words_low)
### We can now generate the word cloud according to the top and low ratings reviews.
set.seed(1234) # for reproducibility
### top ratings
# top_raiting_wc<-wordcloud(words = words_top_df$word, freq = words_top_df$freq, min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35, colors=brewer.pal(8, "Dark2"))
top_rating_wc <- wordcloud2(data = words_top_df, color = "random-dark", size = 0.6, shape = "circle")
top_rating_wc
Entre las principales caracteristicas que se exhiben en un cafe con mejores calificaciones son aquellos que:
Son espaciosos.
Son pet friendly.
Tienen excelente servicio.
Los que abren temprano.
Aquellos en los que te dejan trabajar/estudiar.
Los que tambien ofrecen comida y bebidas (no solo cafe).
En los que sus operadores son atentos.
Que tengan buenos precios.
### low ratings
#low_raiting_wc<-wordcloud(words = words_low_df$word, freq = words_low_df$freq, min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35, colors=brewer.pal(8, "Dark2"))
low_rating_wc <- wordcloud2(data = words_low_df, color = "random-dark", size = 0.6, shape = "circle")
low_rating_wc
Entre las principales caracteristicas que se exhiben en un cafe con bajas calificaciones son aquellos que:
Que les sirvan el cafe helado.
Les queman el cafe.
Son muy caros.
Los baristas y servidores no son amables.
El ambiente no es el mejor.
# Mostrar las 15 palabras más frecuentes para el negocio mejor calificado (ejemplo)
print("Top 15 palabras más frecuentes (negocio mejor calificado):")
## [1] "Top 15 palabras más frecuentes (negocio mejor calificado):"
print(head(words_top_df, 15))
## word freq
## place place 5
## coffee coffee 4
## delicious delicious 4
## caramel caramel 2
## chilaquiles chilaquiles 2
## friendly friendly 2
## good good 2
## latte latte 2
## quiet quiet 2
## soon soon 2
## spacious spacious 2
## nice nice 2
## service service 2
## add add 1
## arrived arrived 1
# Mostrar las 15 palabras más frecuentes para el negocio peor calificado (ejemplo)
print("Top 15 palabras más frecuentes (negocio peor calificado):")
## [1] "Top 15 palabras más frecuentes (negocio peor calificado):"
print(head(words_low_df, 15))
## word freq
## day day 3
## going going 2
## holidays holidays 2
## leave leave 2
## staff staff 2
## good good 2
## possible possible 2
## soon soon 2
## way way 2
## tells tells 2
## better better 1
## improved improved 1
## instalations instalations 1
## lots lots 1
## service service 1
# Calcular los scores de sentimiento para cada reseña
sentiment_scores_top <- get_sentiment(top_ratings_text, method="syuzhet")
sentiment_scores_low <- get_sentiment(low_ratings_text, method="syuzhet")
# Crear dataframes para graficar
sentiment_df_top <- data.frame(score = sentiment_scores_top)
sentiment_df_low <- data.frame(score = sentiment_scores_low)
# Graficar la distribución de scores de sentimiento (Histograma)
ggplot(sentiment_df_top, aes(x=score)) +
geom_histogram(binwidth=1, fill="steelblue", color="black") +
labs(title="Distribución del Sentiment Score (Negocio Mejor Calificado)",
x="Sentiment Score", y="Frecuencia (Nº Reseñas)") +
theme_minimal()
Para los negocios mejor calificados, se ve que hay una distribución claramente sesgada para valores positivos, variando en intensidad pero sin comentarios negativos o neutrales. Esto concuerda perfectamente con su alta calificación promedio y sugiere que los clientes que dejaron estas reseñas tuvieron experiencias muy favorables.
ggplot(sentiment_df_low, aes(x=score)) +
geom_histogram(binwidth=1, fill="lightcoral", color="black") +
labs(title="Distribución del Sentiment Score (Negocio Peor Calificado)",
x="Sentiment Score", y="Frecuencia (Nº Reseñas)") +
theme_minimal()
El sentimiento para estos negocios (que tambien tienen calificación >4.0) es más mixto y menos entusiasta. Hay presencia de sentimiento neutral o cercano a neutral, y los comentarios positivos son menos intensos que los del negocio mejor calificado.
# Obtener emociones usando el léxico NRC
# Nota: Esto puede tardar un poco si hay muchas reseñas.
emotions_top <- get_nrc_sentiment(top_ratings_text)
emotions_low <- get_nrc_sentiment(low_ratings_text)
# Sumar las cuentas de cada emoción (excluyendo columnas 'negative' y 'positive' que son valencias)
emotion_sums_top <- colSums(emotions_top[, 1:8]) # NRC tiene 8 emociones + 2 valencias
emotion_sums_low <- colSums(emotions_low[, 1:8])
# Crear dataframes para graficar
emotion_df_top <- data.frame(emotion = names(emotion_sums_top), count = emotion_sums_top)
emotion_df_low <- data.frame(emotion = names(emotion_sums_low), count = emotion_sums_low)
# Graficar la distribución de emociones
ggplot(emotion_df_top, aes(x=reorder(emotion, -count), y=count, fill=emotion)) +
geom_bar(stat="identity") +
labs(title="Distribución de Emociones (Negocio Mejor Calificado)",
x="Emoción", y="Frecuencia Total") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
guides(fill=FALSE) # Ocultar leyenda si es redundante
El perfil emocional de los cafes mejor calificados es muy positivo. La alta presencia de alegria y confianza sugiere que los clientes estan muy satisfechos con el servicio y los productos que se les ofrece en estos cafes.
ggplot(emotion_df_low, aes(x=reorder(emotion, -count), y=count, fill=emotion)) +
geom_bar(stat="identity") +
labs(title="Distribución de Emociones (Negocio Peor Calificado)",
x="Emoción", y="Frecuencia Total") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
guides(fill=FALSE)
Aunque las emociones positivas siguen siendo las más frecuentes, estas son menores y existe una mezcla detectable de emociones negativas y un nivel más alto de sorpresa, la cual que puede ser positiva o negativa. Esto puede reflejar una base de cliinetes menos consistente o positiva.
# Identificar la emoción más común en cada caso
most_common_emotion_top <- names(which.max(emotion_sums_top))
most_common_emotion_low <- names(which.max(emotion_sums_low))
print(paste("Emoción más común (Mejor Calificado):", most_common_emotion_top))
## [1] "Emoción más común (Mejor Calificado): joy"
print(paste("Emoción más común (Peor Calificado):", most_common_emotion_low))
## [1] "Emoción más común (Peor Calificado): trust"
# Clasificar los scores obtenidos en el Paso 10
classify_sentiment <- function(score) {
ifelse(score > 0, "Positivo",
ifelse(score < 0, "Negativo", "Neutral"))
}
sentiment_class_top <- classify_sentiment(sentiment_scores_top)
sentiment_class_low <- classify_sentiment(sentiment_scores_low)
# Calcular porcentajes
sentiment_dist_top <- prop.table(table(sentiment_class_top)) * 100
sentiment_dist_low <- prop.table(table(sentiment_class_low)) * 100
# Crear dataframes para graficar
sentiment_dist_df_top <- as.data.frame(sentiment_dist_top)
names(sentiment_dist_df_top) <- c("Sentiment", "Percentage")
sentiment_dist_df_low <- as.data.frame(sentiment_dist_low)
names(sentiment_dist_df_low) <- c("Sentiment", "Percentage")
# Graficar la distribución
ggplot(sentiment_dist_df_top, aes(x="", y=Percentage, fill=Sentiment)) +
geom_bar(stat="identity", width=1) +
coord_polar("y", start=0) + # Gráfico de Pay/Dona
geom_text(aes(label = paste0(round(Percentage), "%")), position = position_stack(vjust = 0.5)) +
labs(title="Distribución de Sentimiento (Negocio Mejor Calificado)", x=NULL, y=NULL, fill="Sentimiento") +
theme_void() + # Remover ejes y fondo
theme(legend.position="bottom")
No hubieron reseñas neutrales ni negativas entre los cafes mejor posicionados.
ggplot(sentiment_dist_df_low, aes(x="", y=Percentage, fill=Sentiment)) +
geom_bar(stat="identity", width=1) +
coord_polar("y", start=0) +
geom_text(aes(label = paste0(round(Percentage), "%")), position = position_stack(vjust = 0.5)) +
labs(title="Distribución de Sentimiento (Negocio Peor Calificado)", x=NULL, y=NULL, fill="Sentimiento") +
theme_void() +
theme(legend.position="bottom")
En el caso de los cafes con menor nivel de calificación, la gran mayoria de las reseñas son positivas, sin embargo, cuenta con una porción significativa de comentarios neutrales.
# Mostrar tablas de distribución
print("Distribución de Sentimiento (Mejor Calificado %):")
## [1] "Distribución de Sentimiento (Mejor Calificado %):"
print(sentiment_dist_top)
## sentiment_class_top
## Positivo
## 100
print("Distribución de Sentimiento (Peor Calificado %):")
## [1] "Distribución de Sentimiento (Peor Calificado %):"
print(sentiment_dist_low)
## sentiment_class_low
## Negativo Positivo
## 40 60
Se identifico una fuerte concentración tanto de los coffee shops mejor calificados como los de menor calificación, en la misma zona centro de monterrey. Esto nos sugiere que es un entorno altamente competitivo.
No se observó una correlación directa o fuerte entre tener la calificación más alta y acumular el mayor número de reseñas. Algunos negocios con 5.0 tenían muy pocas reseñas.
Es notable que incluso los negocios identificados con las calificaciones más bajas mantenían promedios superiores a 4.0. Esto podría indicar una calidad general buena de los coffee shops en la zona de búsqueda o un sesgo en los datos.
Kali Coffee Roasters presenta un caso interesante de un negocio con calificación relativamente “baja” (4.5) pero un volumen extremadamente alto de reseñas, lo que sugiere una operación de gran escala o antigüedad donde la experiencia promedio es mixta pero muy comentada.
No solo el tipo de sentimiento diferenció a los cafes, sino también la intensidad. Los negocios mejor calificado mostraron picos de sentimiento muy altos con scores de hasta 7. Mientras que los scores positivos delos negocios peor calificados fueron consistentemente más bajos, principalmente entre 1 y 2.5, indicando un entusiasmo mucho menor incluso en las reseñas positivas.
Una calificación de 4.9 basada en 111 reseñas como Cafetera Mexicana es probablemente un indicador más estable del desempeño general que una calificación de 5.0 basada en 3 reseñas como Fika Coffee Mty o una de 4.1 basada en 68 reseñas como Drew Coffeehouse.
La zona de influencia del Tec de Monterrey actúa como un imán para coffee shops de alta calidad debido a la combinación de una demanda alta y específica por parte de la comunidad universitaria y residente, un perfil demográfico que valora y califica la calidad.