In this report, we will employ various methods to clean the Yelp POI data (restaurants and bars), resulting in a refined dataset that may reveal intriguing insights.
source ("Mini1_code.R")
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
## (status 2 uses the sf package in place of rgdal)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.3 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ purrr::flatten() masks jsonlite::flatten()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'reshape2'
##
##
## The following object is masked from 'package:tidyr':
##
## smiths
##
##
## here() starts at /Users/xy/Downloads/GT
##
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
##
## Please note that rgdal will be retired during October 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
## See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
## rgdal: version: 1.6-7, (SVN revision 1203)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.5.3, released 2022/10/21
## Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rgdal/gdal
## GDAL does not use iconv for recoding strings.
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 9.1.0, September 1st, 2022, [PJ_VERSION: 910]
## Path to PROJ shared files: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.6-1
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
##
## Your original .Renviron will be backed up and stored in your R HOME directory if needed.
##
## Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CENSUS_API_KEY").
## To use now, restart R or run `readRenviron("~/.Renviron")`
##
|
| | 0%
|
|= | 1%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 6%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|========== | 14%
|
|============ | 17%
|
|============== | 19%
|
|=============== | 21%
|
|=============== | 22%
|
|================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|===================== | 30%
|
|======================= | 33%
|
|======================== | 35%
|
|========================= | 35%
|
|========================== | 38%
|
|============================ | 40%
|
|============================= | 42%
|
|=============================== | 45%
|
|================================ | 46%
|
|==================================== | 51%
|
|======================================== | 57%
|
|========================================= | 59%
|
|============================================= | 64%
|
|============================================== | 66%
|
|================================================ | 69%
|
|================================================== | 72%
|
|======================================================= | 78%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=============================================================== | 90%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 95%
|
|===================================================================== | 99%
|
|======================================================================| 100%
## tmap mode set to interactive viewing
## [1] "Current row: 10"
## [1] "Current row: 20"
## [1] "Current row: 30"
## [1] "Current row: 40"
## [1] "Current row: 50"
## [1] "Current row: 60"
## [1] "Current row: 70"
## [1] "Current row: 10"
## [1] "Current row: 20"
## [1] "Current row: 30"
## [1] "Current row: 40"
## [1] "Current row: 50"
## [1] "Current row: 60"
## [1] "Current row: 70"
## # A tibble: 2,594 × 16
## id alias
## <chr> <chr>
## 1 t4XdrDAbx5_9Yb1uLX77mA envegan-morrow
## 2 4Wqj_yFOQj_ecnxKcn8aAg vn-pho-morrow
## 3 Jw_Drfjndv8e_wp-GY_TLg carrabbas-italian-grill-morrow-2
## 4 VIr5uEwR86YXjViV60myCg mi-mexico-tienda-y-taqueria-morrow
## 5 XfKNz-mlaQz7d9Ic0RDXvQ eggs-up-grill-morrow
## 6 J2osdfQe-8Wa6_rsO6BbRQ atlanta-philly-italian-pasta-and-subs-morrow
## 7 RRTA8rRQY--kIr-gSMRs3A eat-more-korean-morrow-4
## 8 M39hcqI3xXcKsq6LwjReSw mr-cow-morrow
## 9 _EeXiC61MQAGnpyAn-aGnw king-claw-juicy-seafood-and-bar-morrow
## 10 X7knQxrMdUEnCe4AR4BR8A greedymans-bar-b-que-and-grill-jonesboro-2
## name
## <chr>
## 1 envegan
## 2 VN Pho
## 3 Carrabba's Italian Grill
## 4 Mi Mexico Tienda y Taqueria
## 5 Eggs Up Grill
## 6 Atlanta Philly Italian Pasta & Subs
## 7 Eat More Korean
## 8 Mr Cow
## 9 King Claw - Juicy Seafood & Bar
## 10 Greedyman's Bar B Que & Grill
## image_url
## <chr>
## 1 https://s3-media3.fl.yelpcdn.com/bphoto/2kj-7AckAs0Wj6V5hH6mKg/o.jpg
## 2 https://s3-media4.fl.yelpcdn.com/bphoto/p0inrlSsokxb4GQ8ihLtQw/o.jpg
## 3 https://s3-media2.fl.yelpcdn.com/bphoto/xy8xa3S8_qVDIJnTJA_Eow/o.jpg
## 4 https://s3-media2.fl.yelpcdn.com/bphoto/M0KHcwRvJN71I8Gd5_lhxA/o.jpg
## 5 https://s3-media2.fl.yelpcdn.com/bphoto/mOoqjjSL3SrfPISL_A4gJg/o.jpg
## 6 https://s3-media1.fl.yelpcdn.com/bphoto/MID73bSYKNB_vFPQYCdg4A/o.jpg
## 7 https://s3-media3.fl.yelpcdn.com/bphoto/tsR1rx-_KAR4OcU2PbxDTQ/o.jpg
## 8 https://s3-media2.fl.yelpcdn.com/bphoto/wKOmKuqLxvPHR3tvvSgyKw/o.jpg
## 9 https://s3-media2.fl.yelpcdn.com/bphoto/Zz9tJaGBYa8jufCSBuQMfg/o.jpg
## 10 https://s3-media3.fl.yelpcdn.com/bphoto/uW9G-WTfMPZyz0AFXK0R_Q/o.jpg
## is_closed
## <lgl>
## 1 FALSE
## 2 FALSE
## 3 FALSE
## 4 FALSE
## 5 FALSE
## 6 FALSE
## 7 FALSE
## 8 FALSE
## 9 FALSE
## 10 FALSE
## url
## <chr>
## 1 https://www.yelp.com/biz/envegan-morrow?adjust_creative=TrPUH-mrbq6wfryDSWK9…
## 2 https://www.yelp.com/biz/vn-pho-morrow?adjust_creative=TrPUH-mrbq6wfryDSWK9R…
## 3 https://www.yelp.com/biz/carrabbas-italian-grill-morrow-2?adjust_creative=Tr…
## 4 https://www.yelp.com/biz/mi-mexico-tienda-y-taqueria-morrow?adjust_creative=…
## 5 https://www.yelp.com/biz/eggs-up-grill-morrow?adjust_creative=TrPUH-mrbq6wfr…
## 6 https://www.yelp.com/biz/atlanta-philly-italian-pasta-and-subs-morrow?adjust…
## 7 https://www.yelp.com/biz/eat-more-korean-morrow-4?adjust_creative=TrPUH-mrbq…
## 8 https://www.yelp.com/biz/mr-cow-morrow?adjust_creative=TrPUH-mrbq6wfryDSWK9R…
## 9 https://www.yelp.com/biz/king-claw-juicy-seafood-and-bar-morrow?adjust_creat…
## 10 https://www.yelp.com/biz/greedymans-bar-b-que-and-grill-jonesboro-2?adjust_c…
## review_count categories rating coordinates$latitude $longitude transactions
## <int> <list> <dbl> <dbl> <dbl> <list>
## 1 291 <df [1 × 2]> 4.5 33.6 -84.3 <chr [2]>
## 2 280 <df [1 × 2]> 4 33.6 -84.3 <chr [2]>
## 3 212 <df [2 × 2]> 3.5 33.6 -84.3 <chr [2]>
## 4 18 <df [3 × 2]> 5 33.6 -84.3 <chr [0]>
## 5 76 <df [3 × 2]> 4 33.6 -84.3 <chr [2]>
## 6 60 <df [3 × 2]> 4.5 33.6 -84.3 <chr [2]>
## 7 111 <df [3 × 2]> 4.5 33.6 -84.3 <chr [2]>
## 8 11 <df [2 × 2]> 5 33.6 -84.3 <chr [0]>
## 9 34 <df [2 × 2]> 4 33.6 -84.3 <chr [2]>
## 10 27 <df [3 × 2]> 5 33.5 -84.3 <chr [2]>
## price location$address1 $address2 $address3 $city $zip_code $country
## <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 $ 1626 Lake Harbin Rd "" <NA> Morrow 30260 US
## 2 $$ 6363 Jonesboro Rd <NA> <NA> Morrow 30260 US
## 3 $$ 1887 Mt Zion Rd "" "" Morrow 30260 US
## 4 <NA> 6777 Mt Zion Blvd <NA> <NA> Morrow 30260 US
## 5 $$ 1990 Mt Zion Rd <NA> "" Morrow 30260 US
## 6 <NA> 1510 Southlake Pkwy "Ste 1E" <NA> Morrow 30260 US
## 7 $ 1940 Mt Zion Rd <NA> <NA> Morrow 30260 US
## 8 <NA> 1940 Mt Zion Rd "" <NA> Morrow 30260 US
## 9 <NA> 1965 Mt Zion Rd <NA> "" Morrow 30260 US
## 10 $$ 1423 Stockbridge Rd <NA> "" Jonesboro 30236 US
## $state $display_address phone display_phone distance
## <chr> <list> <chr> <chr> <dbl>
## 1 GA <chr [2]> "+16785454242" "(678) 545-4242" 1698.
## 2 GA <chr [2]> "+17709606699" "(770) 960-6699" 1911.
## 3 GA <chr [2]> "+17709683233" "(770) 968-3233" 1015.
## 4 GA <chr [2]> "+16785192699" "(678) 519-2699" 926.
## 5 GA <chr [2]> "+14702782917" "(470) 278-2917" 1116.
## 6 GA <chr [3]> "+16784897582" "(678) 489-7582" 1643.
## 7 GA <chr [2]> "+16788379577" "(678) 837-9577" 831.
## 8 GA <chr [2]> "" "" 831.
## 9 GA <chr [2]> "+17704720024" "(770) 472-0024" 1177.
## 10 GA <chr [2]> "+18444733397" "(844) 473-3397" 5490.
## # ℹ 2,584 more rows
## # A tibble: 360 × 16
## id alias
## <chr> <chr>
## 1 4rgCKAEyj4_SUlh6YG-krw red-room-hookah-lounge-college-park
## 2 OHjWsZV5XuH8Zb77C76V5w savoy-bistro-morrow-2
## 3 J7BzvyHHrbxJFLxQyfTADQ tgi-fridays-morrow
## 4 F55BAybX9TyIJe2FnqkivA skyboxx-restaurant-and-sports-bar-morrow
## 5 CX_yxk6GICxopny0uAX5Ew chilis-morrow-2
## 6 V4moL5wTgnUXGTvhvZM3dg rodeo-sports-bar-morrow
## 7 kQmgNLFj7ujsxr5xmFQzbA cru-lounge-morrow-morrow
## 8 im-juAHqpbUsF2yXvF3jdQ the-b-spot-morrow
## 9 RuzLTI0uYh6Kn8uxnCoEuQ bohÃo-restaurant-and-lounge-morrow
## 10 iMzO01QSapoEaNfQX4JOBQ myxers-bar-and-grill-jonesboro
## name
## <chr>
## 1 Red Room Hookah Lounge
## 2 Savoy Bistro
## 3 TGI Fridays
## 4 Skyboxx Restaurant and Sports Bar
## 5 Chili's
## 6 Rodeo Sports Bar
## 7 CRU Lounge Morrow
## 8 The B Spot
## 9 BohÃo Restaurant and Lounge
## 10 Myxers Bar and Grill
## image_url
## <chr>
## 1 https://s3-media3.fl.yelpcdn.com/bphoto/qLcAVc31N89ENJVaOdJdzA/o.jpg
## 2 https://s3-media1.fl.yelpcdn.com/bphoto/UHUr1Qhk_jXmczQq19CWdw/o.jpg
## 3 https://s3-media2.fl.yelpcdn.com/bphoto/z2ylCdwQ8ZvAajtC2tS6bA/o.jpg
## 4 https://s3-media4.fl.yelpcdn.com/bphoto/uikgrv_i1XTC84y6fzr65Q/o.jpg
## 5 https://s3-media4.fl.yelpcdn.com/bphoto/Rr86-bNKkd_bAGixLLsb3g/o.jpg
## 6 https://s3-media3.fl.yelpcdn.com/bphoto/9E8I_R6toHNUdIIrbJfKTA/o.jpg
## 7 https://s3-media4.fl.yelpcdn.com/bphoto/2u-CpuBkJyPPjFk2kaIy8g/o.jpg
## 8 https://s3-media2.fl.yelpcdn.com/bphoto/ggiTGSg2AdIhKIsdFVq6Zw/o.jpg
## 9 https://s3-media2.fl.yelpcdn.com/bphoto/ZT3od-02phePWDBXB883Ug/o.jpg
## 10 https://s3-media2.fl.yelpcdn.com/bphoto/Fabqlut9afxjOTdbtaVJvw/o.jpg
## is_closed
## <lgl>
## 1 FALSE
## 2 FALSE
## 3 FALSE
## 4 FALSE
## 5 FALSE
## 6 FALSE
## 7 FALSE
## 8 FALSE
## 9 FALSE
## 10 FALSE
## url
## <chr>
## 1 https://www.yelp.com/biz/red-room-hookah-lounge-college-park?adjust_creative…
## 2 https://www.yelp.com/biz/savoy-bistro-morrow-2?adjust_creative=TrPUH-mrbq6wf…
## 3 https://www.yelp.com/biz/tgi-fridays-morrow?adjust_creative=TrPUH-mrbq6wfryD…
## 4 https://www.yelp.com/biz/skyboxx-restaurant-and-sports-bar-morrow?adjust_cre…
## 5 https://www.yelp.com/biz/chilis-morrow-2?adjust_creative=TrPUH-mrbq6wfryDSWK…
## 6 https://www.yelp.com/biz/rodeo-sports-bar-morrow?adjust_creative=TrPUH-mrbq6…
## 7 https://www.yelp.com/biz/cru-lounge-morrow-morrow?adjust_creative=TrPUH-mrbq…
## 8 https://www.yelp.com/biz/the-b-spot-morrow?adjust_creative=TrPUH-mrbq6wfryDS…
## 9 https://www.yelp.com/biz/boh%C3%ADo-restaurant-and-lounge-morrow?adjust_crea…
## 10 https://www.yelp.com/biz/myxers-bar-and-grill-jonesboro?adjust_creative=TrPU…
## review_count categories rating coordinates$latitude $longitude transactions
## <int> <list> <dbl> <dbl> <dbl> <list>
## 1 2 <df [1 × 2]> 4 33.6 -84.4 <chr [2]>
## 2 123 <df [3 × 2]> 3.5 33.6 -84.3 <chr [2]>
## 3 161 <df [3 × 2]> 2 33.6 -84.3 <chr [3]>
## 4 139 <df [3 × 2]> 2.5 33.6 -84.3 <chr [2]>
## 5 116 <df [3 × 2]> 2 33.6 -84.3 <chr [2]>
## 6 90 <df [1 × 2]> 2.5 33.6 -84.3 <chr [1]>
## 7 1 <df [3 × 2]> 5 33.6 -84.3 <chr [0]>
## 8 11 <df [3 × 2]> 3.5 33.6 -84.3 <chr [0]>
## 9 2 <df [3 × 2]> 5 33.6 -84.3 <chr [0]>
## 10 1 <df [3 × 2]> 1 33.6 -84.3 <chr [2]>
## location$address1 $address2 $address3 $city $zip_code $country
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 571 Garden Walk Blvd <NA> <NA> College Park 30349 US
## 2 7045 Mount Zion Cir <NA> "" Morrow 30260 US
## 3 1881 Mount Zion Rd "" "" Morrow 30260 US
## 4 2180 Mount Zion Pkwy "" "" Morrow 30236 US
## 5 2230 Mount Zion Pkwy "" "" Morrow 30260 US
## 6 1869 Mt Zion Rd "" <NA> Morrow 30260 US
## 7 1905 Mt Zion Rd "Ste V 25" "" Morrow 30260 US
## 8 6335 Jonesboro Rd "Ste A" "" Morrow 30260 US
## 9 1395 Southlake Pkwy <NA> "" Morrow 30260 US
## 10 2745 Mt Zion Rd <NA> "" Jonesboro 30236 US
## $state $display_address phone display_phone distance price
## <chr> <list> <chr> <chr> <dbl> <chr>
## 1 GA <chr [2]> "+16786076733" "(678) 607-6733" 698. <NA>
## 2 GA <chr [2]> "+17708925238" "(770) 892-5238" 1164. $$
## 3 GA <chr [2]> "+17709683303" "(770) 968-3303" 1020. $$
## 4 GA <chr [2]> "+17704719191" "(770) 471-9191" 1332. $$
## 5 GA <chr [2]> "+17706039900" "(770) 603-9900" 1376. $$
## 6 GA <chr [2]> "+17709687434" "(770) 968-7434" 1029. $$
## 7 GA <chr [3]> "" "" 1285. <NA>
## 8 GA <chr [3]> "+16785451185" "(678) 545-1185" 1958. <NA>
## 9 GA <chr [2]> "+17707031799" "(770) 703-1799" 2229. <NA>
## 10 GA <chr [2]> "+16785865925" "(678) 586-5925" 2746. <NA>
## # ℹ 350 more rows
## # A tibble: 2,954 × 16
## id alias
## <chr> <chr>
## 1 4rgCKAEyj4_SUlh6YG-krw red-room-hookah-lounge-college-park
## 2 OHjWsZV5XuH8Zb77C76V5w savoy-bistro-morrow-2
## 3 J7BzvyHHrbxJFLxQyfTADQ tgi-fridays-morrow
## 4 F55BAybX9TyIJe2FnqkivA skyboxx-restaurant-and-sports-bar-morrow
## 5 CX_yxk6GICxopny0uAX5Ew chilis-morrow-2
## 6 V4moL5wTgnUXGTvhvZM3dg rodeo-sports-bar-morrow
## 7 kQmgNLFj7ujsxr5xmFQzbA cru-lounge-morrow-morrow
## 8 im-juAHqpbUsF2yXvF3jdQ the-b-spot-morrow
## 9 RuzLTI0uYh6Kn8uxnCoEuQ bohÃo-restaurant-and-lounge-morrow
## 10 iMzO01QSapoEaNfQX4JOBQ myxers-bar-and-grill-jonesboro
## name
## <chr>
## 1 Red Room Hookah Lounge
## 2 Savoy Bistro
## 3 TGI Fridays
## 4 Skyboxx Restaurant and Sports Bar
## 5 Chili's
## 6 Rodeo Sports Bar
## 7 CRU Lounge Morrow
## 8 The B Spot
## 9 BohÃo Restaurant and Lounge
## 10 Myxers Bar and Grill
## image_url
## <chr>
## 1 https://s3-media3.fl.yelpcdn.com/bphoto/qLcAVc31N89ENJVaOdJdzA/o.jpg
## 2 https://s3-media1.fl.yelpcdn.com/bphoto/UHUr1Qhk_jXmczQq19CWdw/o.jpg
## 3 https://s3-media2.fl.yelpcdn.com/bphoto/z2ylCdwQ8ZvAajtC2tS6bA/o.jpg
## 4 https://s3-media4.fl.yelpcdn.com/bphoto/uikgrv_i1XTC84y6fzr65Q/o.jpg
## 5 https://s3-media4.fl.yelpcdn.com/bphoto/Rr86-bNKkd_bAGixLLsb3g/o.jpg
## 6 https://s3-media3.fl.yelpcdn.com/bphoto/9E8I_R6toHNUdIIrbJfKTA/o.jpg
## 7 https://s3-media4.fl.yelpcdn.com/bphoto/2u-CpuBkJyPPjFk2kaIy8g/o.jpg
## 8 https://s3-media2.fl.yelpcdn.com/bphoto/ggiTGSg2AdIhKIsdFVq6Zw/o.jpg
## 9 https://s3-media2.fl.yelpcdn.com/bphoto/ZT3od-02phePWDBXB883Ug/o.jpg
## 10 https://s3-media2.fl.yelpcdn.com/bphoto/Fabqlut9afxjOTdbtaVJvw/o.jpg
## is_closed
## <lgl>
## 1 FALSE
## 2 FALSE
## 3 FALSE
## 4 FALSE
## 5 FALSE
## 6 FALSE
## 7 FALSE
## 8 FALSE
## 9 FALSE
## 10 FALSE
## url
## <chr>
## 1 https://www.yelp.com/biz/red-room-hookah-lounge-college-park?adjust_creative…
## 2 https://www.yelp.com/biz/savoy-bistro-morrow-2?adjust_creative=TrPUH-mrbq6wf…
## 3 https://www.yelp.com/biz/tgi-fridays-morrow?adjust_creative=TrPUH-mrbq6wfryD…
## 4 https://www.yelp.com/biz/skyboxx-restaurant-and-sports-bar-morrow?adjust_cre…
## 5 https://www.yelp.com/biz/chilis-morrow-2?adjust_creative=TrPUH-mrbq6wfryDSWK…
## 6 https://www.yelp.com/biz/rodeo-sports-bar-morrow?adjust_creative=TrPUH-mrbq6…
## 7 https://www.yelp.com/biz/cru-lounge-morrow-morrow?adjust_creative=TrPUH-mrbq…
## 8 https://www.yelp.com/biz/the-b-spot-morrow?adjust_creative=TrPUH-mrbq6wfryDS…
## 9 https://www.yelp.com/biz/boh%C3%ADo-restaurant-and-lounge-morrow?adjust_crea…
## 10 https://www.yelp.com/biz/myxers-bar-and-grill-jonesboro?adjust_creative=TrPU…
## review_count categories rating coordinates$latitude $longitude transactions
## <int> <list> <dbl> <dbl> <dbl> <list>
## 1 2 <df [1 × 2]> 4 33.6 -84.4 <chr [2]>
## 2 123 <df [3 × 2]> 3.5 33.6 -84.3 <chr [2]>
## 3 161 <df [3 × 2]> 2 33.6 -84.3 <chr [3]>
## 4 139 <df [3 × 2]> 2.5 33.6 -84.3 <chr [2]>
## 5 116 <df [3 × 2]> 2 33.6 -84.3 <chr [2]>
## 6 90 <df [1 × 2]> 2.5 33.6 -84.3 <chr [1]>
## 7 1 <df [3 × 2]> 5 33.6 -84.3 <chr [0]>
## 8 11 <df [3 × 2]> 3.5 33.6 -84.3 <chr [0]>
## 9 2 <df [3 × 2]> 5 33.6 -84.3 <chr [0]>
## 10 1 <df [3 × 2]> 1 33.6 -84.3 <chr [2]>
## location$address1 $address2 $address3 $city $zip_code $country
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 571 Garden Walk Blvd <NA> <NA> College Park 30349 US
## 2 7045 Mount Zion Cir <NA> "" Morrow 30260 US
## 3 1881 Mount Zion Rd "" "" Morrow 30260 US
## 4 2180 Mount Zion Pkwy "" "" Morrow 30236 US
## 5 2230 Mount Zion Pkwy "" "" Morrow 30260 US
## 6 1869 Mt Zion Rd "" <NA> Morrow 30260 US
## 7 1905 Mt Zion Rd "Ste V 25" "" Morrow 30260 US
## 8 6335 Jonesboro Rd "Ste A" "" Morrow 30260 US
## 9 1395 Southlake Pkwy <NA> "" Morrow 30260 US
## 10 2745 Mt Zion Rd <NA> "" Jonesboro 30236 US
## $state $display_address phone display_phone distance price
## <chr> <list> <chr> <chr> <dbl> <chr>
## 1 GA <chr [2]> "+16786076733" "(678) 607-6733" 698. <NA>
## 2 GA <chr [2]> "+17708925238" "(770) 892-5238" 1164. $$
## 3 GA <chr [2]> "+17709683303" "(770) 968-3303" 1020. $$
## 4 GA <chr [2]> "+17704719191" "(770) 471-9191" 1332. $$
## 5 GA <chr [2]> "+17706039900" "(770) 603-9900" 1376. $$
## 6 GA <chr [2]> "+17709687434" "(770) 968-7434" 1029. $$
## 7 GA <chr [3]> "" "" 1285. <NA>
## 8 GA <chr [3]> "+16785451185" "(678) 545-1185" 1958. <NA>
## 9 GA <chr [2]> "+17707031799" "(770) 703-1799" 2229. <NA>
## 10 GA <chr [2]> "+16785865925" "(678) 586-5925" 2746. <NA>
## # ℹ 2,944 more rows
dirtydata_restaurants <- yelp_restaurants
dirtydata_bars <- yelp_bars
dirtydata_all <- yelp_all
claton_tract <- tract
print(dirtydata_all)
## # A tibble: 2,954 × 16
## id alias name image_url is_closed url review_count categories rating
## <chr> <chr> <chr> <chr> <lgl> <chr> <int> <list> <dbl>
## 1 4rgCKAE… red-… Red … https://… FALSE http… 2 <df> 4
## 2 OHjWsZV… savo… Savo… https://… FALSE http… 123 <df> 3.5
## 3 J7BzvyH… tgi-… TGI … https://… FALSE http… 161 <df> 2
## 4 F55BAyb… skyb… Skyb… https://… FALSE http… 139 <df> 2.5
## 5 CX_yxk6… chil… Chil… https://… FALSE http… 116 <df> 2
## 6 V4moL5w… rode… Rode… https://… FALSE http… 90 <df> 2.5
## 7 kQmgNLF… cru-… CRU … https://… FALSE http… 1 <df> 5
## 8 im-juAH… the-… The … https://… FALSE http… 11 <df> 3.5
## 9 RuzLTI0… bohÃ… BohÃ… https://… FALSE http… 2 <df> 5
## 10 iMzO01Q… myxe… Myxe… https://… FALSE http… 1 <df> 1
## # ℹ 2,944 more rows
## # ℹ 7 more variables: coordinates <df[,2]>, transactions <list>,
## # location <df[,8]>, phone <chr>, display_phone <chr>, distance <dbl>,
## # price <chr>
# For restaurants and bars separately
restaurants_unique <- dirtydata_restaurants %>%
distinct(id, .keep_all=T)
bars_unique <- dirtydata_bars %>%
distinct(id, .keep_all=T)
glue::glue("Before dropping duplicated rows, there were {nrow(dirtydata_restaurants)} rows for restaurants, {nrow(dirtydata_bars)} rows for bars. After dropping them, there are {nrow(restaurants_unique)} rows for restaurants, {nrow(bars_unique)} rows for bars.") %>%
print()
## Before dropping duplicated rows, there were 2594 rows for restaurants, 360 rows for bars. After dropping them, there are 763 rows for restaurants, 126 rows for bars.
#for all
yelp_unique <- dirtydata_all %>%
distinct(id, .keep_all=T)
glue::glue("Before dropping duplicated rows, there were {nrow(dirtydata_all)} rows. After dropping them, there are {nrow(yelp_unique)} rows") %>%
print()
## Before dropping duplicated rows, there were 2954 rows. After dropping them, there are 821 rows
concate_list <- function(x){
titles <- x[["title"]] %>% str_c(collapse = ", ")
return(titles)
}
yelp_flat <- yelp_unique %>%
# Flattening columns with data frame
jsonlite::flatten() %>%
# Handling list-columns
mutate(transactions = transactions %>%
map_chr(., function(x) str_c(x, collapse=", ")),
location.display_address = location.display_address %>%
map_chr(., function(x) str_c(x, collapse=", ")),
categories = categories %>% map_chr(concate_list))
# concate_list is the custom function
# check whether there exists any NA in coor
yelp_flat %>%
map_dbl(., function(x) sum(is.na(x)))
## id alias name
## 0 0 0
## image_url is_closed url
## 0 0 0
## review_count categories rating
## 0 0 0
## transactions phone display_phone
## 0 0 0
## distance price coordinates.latitude
## 0 310 0
## coordinates.longitude location.address1 location.address2
## 0 4 203
## location.address3 location.city location.zip_code
## 294 0 0
## location.country location.state location.display_address
## 0 0 0
# woohoo~ there is no NA in 'coordinates' variable
# census boundary
census <- st_read("https://raw.githubusercontent.com/ujhwang/UrbanAnalytics2023/main/Lab/module_0/testdata.geojson")
## Reading layer `testdata' from data source
## `https://raw.githubusercontent.com/ujhwang/UrbanAnalytics2023/main/Lab/module_0/testdata.geojson'
## using driver `GeoJSON'
## Simple feature collection with 519 features and 8 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -84.85071 ymin: 33.35246 xmax: -84.02371 ymax: 34.18629
## Geodetic CRS: WGS 84
# Converting yelp_dropna2 into a sf object
yelp_sf <- yelp_flat %>%
st_as_sf(coords=c("coordinates.longitude", "coordinates.latitude"), crs = 4326)
# sf subsets
yelp_in <- yelp_sf[census %>%
filter(county %in% c("Clayton County")) %>%
st_union(), ,op = st_intersects]
# visualize the clean data
tm_shape(yelp_in) +
tm_dots(col = "review_count", style="quantile")
Restaurants and bars in the northwest have the highest number of reviews, to some extent indicating that restaurants and bars in the northwest corner are the most popular in the entire county, followed by the central region. This observation remained consistent before and after data cleaning.
# Dropping NAs in rating scores
yelp_dropna1 <- yelp_in %>%
drop_na(rating)
# Dropping NAs in price
yelp_dropna2 <- yelp_dropna1 %>%
drop_na(price)
# Use the table() function to count rows for each unique rating
rating_counts <- table(yelp_dropna2$rating)
# Create a bar plot of the rating counts
barplot(rating_counts,
main = "Rating Counts",
xlab = "Rating",
ylab = "Count",
col = "orange")
We created statistical charts to examine the distribution of ratings in tidy data and found that restaurants and bars with a rating of 3.5 are the most common, followed by those with a rating of 3, as well as ratings between 1 and 2.5.
# Visualize rating scores of these restaurants and bars
tm_shape(yelp_dropna2) +
tm_dots(col = "rating", style="quantile")
On the map, we noticed that restaurants and bars in Clayton County with ratings above 3.5 are primarily concentrated in the northern and central areas. Restaurants and bars with a higher number of reviews (such as clusters in the northwest) also tend to have higher ratings.
# Use the table() function to count rows for each unique price
price_counts <- table(yelp_dropna2$price)
# Create a bar plot of the rating counts
barplot(price_counts,
main = "Rating Counts",
xlab = "Rating",
ylab = "Count",
col = "skyblue")
# Visualize price of these restaurants and bars
tm_shape(yelp_dropna2) +
tm_dots(col = "price", style="quantile")
Regarding the prices of restaurants and bars in Clayton County, we found that the majority are either low-priced or moderately priced. Expensive restaurants and bars are more prevalent in the northwest and central areas. Restaurants and bars with a higher number of reviews (such as those in the northwest clusters) tend to be moderately priced or higher, but this correlation requires further verification.
The most reviewed restaurants and bars are in the northwest, indicating their popularity in Clayton County, followed by the central area, a trend unchanged before and after tidying the data.Examining the ratings in tidy data, we found that restaurants and bars with a 3.5 rating were most common, followed by 3-star ratings and 1-2.5 star ratings. On the map, 3.5+ rated establishments are mainly in the north and central regions. Highly reviewed ones, such as the northwest cluster, tend to have higher ratings.Most restaurants and bars in Clayton County are low or moderately priced. Expensive ones are in the northwest and central areas. Highly reviewed places, like the northwest cluster, are moderately priced or higher, but this needs further validation.Interestingly, the northwest dining cluster is within the airport with heavy foot traffic, aligning with our findings.