library(tidycensus)
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(tmap)
## 
## Attaching package: 'tmap'
## The following object is masked from 'package:datasets':
## 
##     rivers
library(jsonlite)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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
library(httr)
library(jsonlite)
library(reshape2)
## 
## Attaching package: 'reshape2'
## 
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(here)
## here() starts at /Users/ryannation
library(yelpr)
library(knitr)
Sys.getenv("CENSUS_API_KEY")
## [1] "961ba65800413985d189b3b1531d55702e8447ae"
Sys.getenv("YELP_API_KEY")
## [1] "MnNAWxqA9z-JhW8pqQUV43HbcPthPJPGDClzTRS-X5tCuJN8cCrgIYL_UWTbLgFKAURIiWSNpUrHpQdtoX-1NIFgS0XXBq-fMSv8ptMiqFgywaCAMJ_wTykKntHYZnYx"
tract <- suppressMessages(
  get_acs(geography = "tract",
          state = "SC",
          county = c("Oconee"),
          variables = c(hhincome = 'B19019_001'),
          year = 2020,
          survey = "acs5",
          geometry = TRUE,
          output = "wide")
)
##   |                                                                              |                                                                      |   0%  |                                                                              |=                                                                     |   1%  |                                                                              |==                                                                    |   2%  |                                                                              |===                                                                   |   4%  |                                                                              |===                                                                   |   5%  |                                                                              |====                                                                  |   6%  |                                                                              |=====                                                                 |   7%  |                                                                              |======                                                                |   8%  |                                                                              |=======                                                               |  10%  |                                                                              |========                                                              |  11%  |                                                                              |========                                                              |  12%  |                                                                              |=========                                                             |  13%  |                                                                              |==========                                                            |  15%  |                                                                              |===========                                                           |  16%  |                                                                              |============                                                          |  17%  |                                                                              |=============                                                         |  18%  |                                                                              |=============                                                         |  19%  |                                                                              |==============                                                        |  20%  |                                                                              |===============                                                       |  21%  |                                                                              |================                                                      |  23%  |                                                                              |=================                                                     |  24%  |                                                                              |==================                                                    |  25%  |                                                                              |==================                                                    |  26%  |                                                                              |===================                                                   |  28%  |                                                                              |====================                                                  |  29%  |                                                                              |=====================                                                 |  30%  |                                                                              |======================                                                |  31%  |                                                                              |=======================                                               |  32%  |                                                                              |=======================                                               |  34%  |                                                                              |========================                                              |  35%  |                                                                              |=========================                                             |  36%  |                                                                              |==========================                                            |  37%  |                                                                              |===========================                                           |  38%  |                                                                              |============================                                          |  40%  |                                                                              |=============================                                         |  41%  |                                                                              |=============================                                         |  42%  |                                                                              |==============================                                        |  43%  |                                                                              |===============================                                       |  44%  |                                                                              |================================                                      |  46%  |                                                                              |=================================                                     |  47%  |                                                                              |==================================                                    |  48%  |                                                                              |==================================                                    |  49%  |                                                                              |===================================                                   |  50%  |                                                                              |====================================                                  |  52%  |                                                                              |=====================================                                 |  53%  |                                                                              |======================================                                |  54%  |                                                                              |=======================================                               |  55%  |                                                                              |========================================                              |  56%  |                                                                              |========================================                              |  58%  |                                                                              |=========================================                             |  59%  |                                                                              |==========================================                            |  60%  |                                                                              |===========================================                           |  61%  |                                                                              |============================================                          |  62%  |                                                                              |=============================================                         |  64%  |                                                                              |=============================================                         |  65%  |                                                                              |==============================================                        |  66%  |                                                                              |===============================================                       |  67%  |                                                                              |================================================                      |  68%  |                                                                              |=================================================                     |  70%  |                                                                              |==================================================                    |  71%  |                                                                              |==================================================                    |  72%  |                                                                              |===================================================                   |  73%  |                                                                              |====================================================                  |  75%  |                                                                              |=====================================================                 |  76%  |                                                                              |======================================================                |  77%  |                                                                              |=======================================================               |  78%  |                                                                              |=======================================================               |  79%  |                                                                              |========================================================              |  80%  |                                                                              |=========================================================             |  82%  |                                                                              |==========================================================            |  83%  |                                                                              |===========================================================           |  84%  |                                                                              |============================================================          |  85%  |                                                                              |=============================================================         |  87%  |                                                                              |=============================================================         |  88%  |                                                                              |==============================================================        |  89%  |                                                                              |===============================================================       |  90%  |                                                                              |================================================================      |  91%  |                                                                              |=================================================================     |  93%  |                                                                              |==================================================================    |  94%  |                                                                              |==================================================================    |  95%  |                                                                              |===================================================================   |  96%  |                                                                              |====================================================================  |  97%  |                                                                              |===================================================================== |  99%  |                                                                              |======================================================================| 100%
seneca<- tigris::places('SC') %>%
  filter(NAME == 'Seneca')
## Retrieving data for the year 2022
##   |                                                                              |                                                                      |   0%  |                                                                              |                                                                      |   1%  |                                                                              |=                                                                     |   1%  |                                                                              |=                                                                     |   2%  |                                                                              |==                                                                    |   2%  |                                                                              |==                                                                    |   3%  |                                                                              |===                                                                   |   4%  |                                                                              |===                                                                   |   5%  |                                                                              |====                                                                  |   5%  |                                                                              |====                                                                  |   6%  |                                                                              |=====                                                                 |   7%  |                                                                              |=====                                                                 |   8%  |                                                                              |======                                                                |   8%  |                                                                              |======                                                                |   9%  |                                                                              |=======                                                               |   9%  |                                                                              |=======                                                               |  10%  |                                                                              |=======                                                               |  11%  |                                                                              |========                                                              |  11%  |                                                                              |========                                                              |  12%  |                                                                              |=========                                                             |  12%  |                                                                              |=========                                                             |  13%  |                                                                              |=========                                                             |  14%  |                                                                              |==========                                                            |  14%  |                                                                              |==========                                                            |  15%  |                                                                              |===========                                                           |  15%  |                                                                              |===========                                                           |  16%  |                                                                              |============                                                          |  16%  |                                                                              |============                                                          |  17%  |                                                                              |============                                                          |  18%  |                                                                              |=============                                                         |  18%  |                                                                              |=============                                                         |  19%  |                                                                              |==============                                                        |  19%  |                                                                              |==============                                                        |  20%  |                                                                              |==============                                                        |  21%  |                                                                              |===============                                                       |  21%  |                                                                              |===============                                                       |  22%  |                                                                              |================                                                      |  22%  |                                                                              |================                                                      |  23%  |                                                                              |=================                                                     |  24%  |                                                                              |=================                                                     |  25%  |                                                                              |==================                                                    |  25%  |                                                                              |==================                                                    |  26%  |                                                                              |===================                                                   |  26%  |                                                                              |===================                                                   |  27%  |                                                                              |===================                                                   |  28%  |                                                                              |====================                                                  |  28%  |                                                                              |====================                                                  |  29%  |                                                                              |=====================                                                 |  29%  |                                                                              |=====================                                                 |  30%  |                                                                              |======================                                                |  31%  |                                                                              |======================                                                |  32%  |                                                                              |=======================                                               |  32%  |                                                                              |=======================                                               |  33%  |                                                                              |========================                                              |  34%  |                                                                              |========================                                              |  35%  |                                                                              |=========================                                             |  35%  |                                                                              |=========================                                             |  36%  |                                                                              |==========================                                            |  37%  |                                                                              |==========================                                            |  38%  |                                                                              |===========================                                           |  38%  |                                                                              |===========================                                           |  39%  |                                                                              |============================                                          |  39%  |                                                                              |============================                                          |  40%  |                                                                              |=============================                                         |  41%  |                                                                              |=============================                                         |  42%  |                                                                              |==============================                                        |  42%  |                                                                              |==============================                                        |  43%  |                                                                              |===============================                                       |  44%  |                                                                              |===============================                                       |  45%  |                                                                              |================================                                      |  45%  |                                                                              |================================                                      |  46%  |                                                                              |=================================                                     |  47%  |                                                                              |=================================                                     |  48%  |                                                                              |==================================                                    |  48%  |                                                                              |==================================                                    |  49%  |                                                                              |===================================                                   |  49%  |                                                                              |===================================                                   |  50%  |                                                                              |====================================                                  |  51%  |                                                                              |====================================                                  |  52%  |                                                                              |=====================================                                 |  52%  |                                                                              |=====================================                                 |  53%  |                                                                              |======================================                                |  54%  |                                                                              |======================================                                |  55%  |                                                                              |=======================================                               |  55%  |                                                                              |=======================================                               |  56%  |                                                                              |========================================                              |  57%  |                                                                              |========================================                              |  58%  |                                                                              |=========================================                             |  58%  |                                                                              |=========================================                             |  59%  |                                                                              |==========================================                            |  60%  |                                                                              |===========================================                           |  61%  |                                                                              |===========================================                           |  62%  |                                                                              |============================================                          |  62%  |                                                                              |============================================                          |  63%  |                                                                              |=============================================                         |  64%  |                                                                              |=============================================                         |  65%  |                                                                              |==============================================                        |  65%  |                                                                              |==============================================                        |  66%  |                                                                              |===============================================                       |  67%  |                                                                              |===============================================                       |  68%  |                                                                              |================================================                      |  68%  |                                                                              |================================================                      |  69%  |                                                                              |=================================================                     |  70%  |                                                                              |=================================================                     |  71%  |                                                                              |==================================================                    |  71%  |                                                                              |==================================================                    |  72%  |                                                                              |===================================================                   |  72%  |                                                                              |===================================================                   |  73%  |                                                                              |====================================================                  |  74%  |                                                                              |====================================================                  |  75%  |                                                                              |=====================================================                 |  75%  |                                                                              |=====================================================                 |  76%  |                                                                              |======================================================                |  77%  |                                                                              |=======================================================               |  78%  |                                                                              |=======================================================               |  79%  |                                                                              |========================================================              |  80%  |                                                                              |========================================================              |  81%  |                                                                              |=========================================================             |  81%  |                                                                              |=========================================================             |  82%  |                                                                              |==========================================================            |  82%  |                                                                              |==========================================================            |  83%  |                                                                              |===========================================================           |  84%  |                                                                              |===========================================================           |  85%  |                                                                              |============================================================          |  85%  |                                                                              |============================================================          |  86%  |                                                                              |=============================================================         |  87%  |                                                                              |=============================================================         |  88%  |                                                                              |==============================================================        |  88%  |                                                                              |==============================================================        |  89%  |                                                                              |===============================================================       |  89%  |                                                                              |===============================================================       |  90%  |                                                                              |===============================================================       |  91%  |                                                                              |================================================================      |  91%  |                                                                              |================================================================      |  92%  |                                                                              |=================================================================     |  92%  |                                                                              |=================================================================     |  93%  |                                                                              |==================================================================    |  94%  |                                                                              |==================================================================    |  95%  |                                                                              |===================================================================   |  95%  |                                                                              |===================================================================   |  96%  |                                                                              |====================================================================  |  97%  |                                                                              |====================================================================  |  98%  |                                                                              |===================================================================== |  98%  |                                                                              |===================================================================== |  99%  |                                                                              |======================================================================|  99%  |                                                                              |======================================================================| 100%
tract_seneca <- tract[seneca,]

message(sprintf("nrow: %s, ncol: %s", nrow(tract_seneca),ncol(tract_seneca)))
## nrow: 7, ncol: 5
tract_seneca %>% head() %>% knitr::kable()
GEOID NAME hhincomeE hhincomeM geometry
2 45073030601 Census Tract 306.01, Oconee County, South Carolina 69107 17252 MULTIPOLYGON (((-83.04233 3…
5 45073030602 Census Tract 306.02, Oconee County, South Carolina 48017 7674 MULTIPOLYGON (((-82.93847 3…
6 45073030802 Census Tract 308.02, Oconee County, South Carolina 52404 17864 MULTIPOLYGON (((-83.02867 3…
8 45073030702 Census Tract 307.02, Oconee County, South Carolina 41875 7023 MULTIPOLYGON (((-82.94606 3…
17 45073030701 Census Tract 307.01, Oconee County, South Carolina 43233 12026 MULTIPOLYGON (((-82.95646 3…
19 45073030801 Census Tract 308.01, Oconee County, South Carolina 33981 1739 MULTIPOLYGON (((-82.96989 3…

#Census Tract information for Seneca, SC

tm_shape(tract_seneca) + tm_borders(lwd = 2) +
  tm_shape(seneca) + tm_polygons(col = 'blue', alpha = 0.4)
## 
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] tm_polygons(): use 'fill' for the fill color of polygons/symbols (instead of 'col'), and 'col' for the outlines (instead of 'border.col')
## [v3->v4] `tm_polygons()`: use `fill_alpha` instead of `alpha`.

seneca, sc with census tracts
seneca, sc with census tracts

#See image above

hotels <- business_search(api_key = Sys.getenv("YELP_API_KEY"),
                          categories = "hotels",
                          latitude = 34.684145,
                          longitude = -82.955778,
                          offset = 0,
                          radius = 2000,
                          limit = 50)
## No encoding supplied: defaulting to UTF-8.
lapply(hotels, head)
## $businesses
##                       id
## 1 y_Cd_EK1NtllPUZwknesNg
## 2 Mb0vnKkL7SsgKaB0qTEVOg
## 3 owLt3_5SlpPCNkXvDGk9FA
## 4 c8i_TggkmACZD2BRsytNZQ
## 5 Isz2URaw-98VamE8xIpnmw
## 6 GMpbnt9K2EH3oUBowv1b5A
##                                                      alias
## 1        hampton-inn-and-suites-seneca-clemson-area-seneca
## 2                                   lowry-house-inn-seneca
## 3                       best-western-seneca-clemson-seneca
## 4 fairfield-inn-and-suites-seneca-clemson-univ-area-seneca
## 5                                      best-way-inn-seneca
## 6                            town-and-country-motel-seneca
##                                              name
## 1        Hampton Inn & Suites Seneca-Clemson Area
## 2                                 Lowry House Inn
## 3                     Best Western Seneca-Clemson
## 4 Fairfield Inn & Suites Seneca Clemson Univ Area
## 5                                    Best Way Inn
## 6                          Town and Country Motel
##                                                              image_url
## 1 https://s3-media1.fl.yelpcdn.com/bphoto/kFuPK9xDV5FXTeS5zVlpzw/o.jpg
## 2 https://s3-media4.fl.yelpcdn.com/bphoto/vHic50jCCh1d6-M-JULqAQ/o.jpg
## 3 https://s3-media1.fl.yelpcdn.com/bphoto/vfWwQvNlI-afoufiQnJSWg/o.jpg
## 4 https://s3-media4.fl.yelpcdn.com/bphoto/OCVHN3BjUO4_RGbidSE1zQ/o.jpg
## 5                                                                     
## 6                                                                     
##   is_closed
## 1     FALSE
## 2     FALSE
## 3     FALSE
## 4     FALSE
## 5     FALSE
## 6     FALSE
##                                                                                                                                                                                                                     url
## 1        https://www.yelp.com/biz/hampton-inn-and-suites-seneca-clemson-area-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 2                                   https://www.yelp.com/biz/lowry-house-inn-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 3                       https://www.yelp.com/biz/best-western-seneca-clemson-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 4 https://www.yelp.com/biz/fairfield-inn-and-suites-seneca-clemson-univ-area-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 5                                      https://www.yelp.com/biz/best-way-inn-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 6                            https://www.yelp.com/biz/town-and-country-motel-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
##   review_count                                    categories rating
## 1           21                                hotels, Hotels    3.9
## 2            0 hotels, bedbreakfast, Hotels, Bed & Breakfast    0.0
## 3           13                                hotels, Hotels    2.7
## 4            2                                hotels, Hotels    5.0
## 5            0                                hotels, Hotels    0.0
## 6            1                                hotels, Hotels    1.0
##   coordinates.latitude coordinates.longitude transactions price
## 1             34.69846             -82.94044         NULL    $$
## 2             34.68153             -82.95481         NULL  <NA>
## 3             34.69659             -82.95338         NULL  <NA>
## 4             34.69757             -82.96548         NULL  <NA>
## 5             34.69962             -82.94113         NULL  <NA>
## 6             34.69811             -82.94573         NULL  <NA>
##     location.address1 location.address2 location.address3 location.city
## 1 1011 E North 1st St                                            Seneca
## 2   206 S Fairplay St              <NA>              <NA>        Seneca
## 3     511 Byp Hwy 123                                            Seneca
## 4      800 Bypass 123                                <NA>        Seneca
## 5     320 By Pass 123                                            Seneca
## 6     320 By Pass 123                                            Seneca
##   location.zip_code location.country location.state
## 1             29678               US             SC
## 2             29678               US             SC
## 3             29678               US             SC
## 4        29678-2521               US             SC
## 5             29678               US             SC
## 6             29678               US             SC
##                location.display_address        phone  display_phone  distance
## 1 1011 E North 1st St, Seneca, SC 29678 +18644822900 (864) 482-2900 2121.3979
## 2   206 S Fairplay St, Seneca, SC 29678 +18648880122 (864) 888-0122  305.5516
## 3     511 Byp Hwy 123, Seneca, SC 29678 +18648869646 (864) 886-9646 1401.4802
## 4 800 Bypass 123, Seneca, SC 29678-2521 +18558166193 (855) 816-6193 1736.8687
## 5     320 By Pass 123, Seneca, SC 29678 +18648823376 (864) 882-3376 2180.3225
## 6     320 By Pass 123, Seneca, SC 29678 +18648823376 (864) 882-3376 1803.6679
##                                                                                                                                                     business_hours
## 1 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE
## 2                                                                                                                                                             NULL
## 3 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE
## 4                                                                                                                                                             NULL
## 5                                                                                                                                                             NULL
## 6                                                                                                                                                             NULL
##   attributes.business_temp_closed attributes.waitlist_reservation
## 1                              NA                              NA
## 2                              NA                              NA
## 3                              NA                              NA
## 4                              NA                              NA
## 5                              NA                              NA
## 6                              NA                              NA
## 
## $total
## [1] 8
## 
## $region
## $region$center
## $region$center$longitude
## [1] -82.95578
## 
## $region$center$latitude
## [1] 34.68415

#Code chunk sets up Yelp request, and searches for Hotels in Seneca, SC based on long/lat. There are less than 50 hotels in the town, hence no need for multiple searches.

df <- data.frame(
  id = 1:2,
  longitude = c(-82.94044, -82.95481, -82.95338, -82.96548, -82.4113, -82.94573, -82.94096, -82.94233),
  latitude = c(34.69846, 34.68153, 34.69659, 34.69757, 34.69962, 34.69811, 34.69780, 34.69842))

hotels_sf <- st_as_sf(df, coords = c("longitude", "latitude"), crs = 4326)

#Code Chunk to convert data from data frame to simple coordinates.

tm_shape(hotels_sf) + tm_dots()

#Create plot of hotels in Seneca

seneca hotels
seneca hotels
active_living <- business_search(api_key = Sys.getenv("YELP_API_KEY"),
                                 categories = "active",
                                 latitude = 34.684145,
                                 longitude = -82.955778,
                                 offset = 0,
                                 radius = 2500,
                                 limit = 50)
## No encoding supplied: defaulting to UTF-8.
lapply(active_living, head)
## $businesses
##                       id                         alias                   name
## 1 jrCLRhmnP5Fl9fxnlddZKQ   healing-arts-pilates-seneca   Healing Arts Pilates
## 2 f9aadAy54oqeRmtwtpxwvA         borrowed-boats-seneca         Borrowed Boats
## 3 lsUQUV6SsIEuALsV7qQujQ  seneca-escape-zones-seneca-2    Seneca Escape Zones
## 4 UBt9QYx7HPiXaN0DWVoSgA upstate-dive-solutions-seneca Upstate Dive Solutions
## 5 ToMmOYoQg-szjIX7aeYOlw         the-wild-child-seneca         The Wild Child
## 6 KkC1tqtauOgb0fMOjn0Prg     yus-karate-academy-seneca    Yu's Karate Academy
##                                                              image_url
## 1 https://s3-media4.fl.yelpcdn.com/bphoto/5wnG-4lxSVEtD24_PYAR9w/o.jpg
## 2 https://s3-media2.fl.yelpcdn.com/bphoto/Xn4ltD9U1alQdfadfOcZOA/o.jpg
## 3 https://s3-media2.fl.yelpcdn.com/bphoto/HC97yH7UHtSCbpGA-9a48g/o.jpg
## 4 https://s3-media3.fl.yelpcdn.com/bphoto/naGP5VK7Zq_CeaIvoH1ejA/o.jpg
## 5                                                                     
## 6                                                                     
##   is_closed
## 1     FALSE
## 2     FALSE
## 3     FALSE
## 4     FALSE
## 5     FALSE
## 6     FALSE
##                                                                                                                                                                                          url
## 1   https://www.yelp.com/biz/healing-arts-pilates-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 2         https://www.yelp.com/biz/borrowed-boats-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 3  https://www.yelp.com/biz/seneca-escape-zones-seneca-2?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 4 https://www.yelp.com/biz/upstate-dive-solutions-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 5         https://www.yelp.com/biz/the-wild-child-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
## 6     https://www.yelp.com/biz/yus-karate-academy-seneca?adjust_creative=zvy74TOg3PFhaK2y5NKr6w&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=zvy74TOg3PFhaK2y5NKr6w
##   review_count
## 1            2
## 2            0
## 3            4
## 4            0
## 5            0
## 6            0
##                                                                    categories
## 1                                                            pilates, Pilates
## 2 rafting, boating, paddleboarding, Rafting/Kayaking, Boating, Paddleboarding
## 3                                                   escapegames, Escape Games
## 4                                                         scuba, Scuba Diving
## 5                                        indoor_playcenter, Indoor Playcentre
## 6                                                              karate, Karate
##   rating coordinates.latitude coordinates.longitude transactions
## 1      5             34.68623             -82.94979         NULL
## 2      0             34.68566             -82.95320         NULL
## 3      5             34.69666             -82.95072         NULL
## 4      0             34.68220             -82.95125         NULL
## 5      0             34.68514             -82.95295         NULL
## 6      0             34.68573             -82.95457         NULL
##    location.address1 location.address2 location.address3 location.city
## 1 401 E North 1st St              <NA>                          Seneca
## 2                                 <NA>                          Seneca
## 3 115 Eagles Nest Dr             Ste C                          Seneca
## 4                                 <NA>                          Seneca
## 5        203 Main St              <NA>                          Seneca
## 6 113 E North 1st St                                            Seneca
##   location.zip_code location.country location.state
## 1             29678               US             SC
## 2             29678               US             SC
## 3             29678               US             SC
## 4             29678               US             SC
## 5             29678               US             SC
## 6             29678               US             SC
##                      location.display_address        phone  display_phone
## 1        401 E North 1st St, Seneca, SC 29678 +13158792818 (315) 879-2818
## 2                            Seneca, SC 29678 +18439917784 (843) 991-7784
## 3 115 Eagles Nest Dr, Ste C, Seneca, SC 29678 +18645579663 (864) 557-9663
## 4                            Seneca, SC 29678 +18642807061 (864) 280-7061
## 5               203 Main St, Seneca, SC 29678 +18645060188 (864) 506-0188
## 6        113 E North 1st St, Seneca, SC 29678 +18648888899 (864) 888-8899
##    distance
## 1  594.4947
## 2  289.1692
## 3 1466.7471
## 4  289.1692
## 5  280.9717
## 6  277.2168
##                                                                                                                                                            business_hours
## 1                                            FALSE, FALSE, FALSE, FALSE, FALSE, 0700, 0700, 0700, 0700, 0700, 1400, 1730, 1400, 1400, 1200, 1, 2, 3, 4, 5, REGULAR, FALSE
## 2 FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0830, 0830, 0830, 0830, 0830, 0830, 0830, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 0, 1, 2, 3, 4, 5, 6, REGULAR, TRUE
## 3                                             FALSE, FALSE, FALSE, FALSE, FALSE, 1200, 1200, 1200, 1200, 1200, 2100, 2100, 2100, 2100, 2100, 0, 1, 3, 4, 5, REGULAR, TRUE
## 4                      FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, 0800, 0800, 0800, 0800, 0800, 0800, 1700, 1700, 1700, 1700, 1700, 1700, 0, 1, 2, 3, 4, 5, REGULAR, FALSE
## 5                                             FALSE, FALSE, FALSE, FALSE, FALSE, 1000, 1000, 1000, 1000, 1000, 1800, 1800, 1800, 2030, 2030, 0, 1, 2, 3, 4, REGULAR, TRUE
## 6                                                                                                                                                                    NULL
##   attributes.business_temp_closed attributes.waitlist_reservation
## 1                              NA                              NA
## 2                              NA                              NA
## 3                              NA                              NA
## 4                              NA                              NA
## 5                              NA                              NA
## 6                              NA                              NA
##   attributes.menu_url attributes.open24_hours
## 1                <NA>                      NA
## 2                <NA>                      NA
## 3                <NA>                      NA
## 4                <NA>                      NA
## 5                <NA>                      NA
## 6                <NA>                      NA
## 
## $total
## [1] 28
## 
## $region
## $region$center
## $region$center$longitude
## [1] -82.95578
## 
## $region$center$latitude
## [1] 34.68415

#Second Yelp search for recreational businesses

active_coordinates <- data.frame(
  Latitude = c(34.68623, 34.68566, 34.69666, 34.68220, 34.68514, 34.68573, 34.68539, 34.68580, 34.87822, 34.63303, 34.71162, 34.69783, 34.69967, 34.94891, 34.69117, 34.88444, 34.79039, 34.69967, 34.69909, 34.68644, 34.68644, 34.38024, 34.69230, 34.65637, 34.67452, 34.70035, 34.69144, 34.69047),
  Longitude = c(-82.94979, -82.95320, -82.95072, -82.95125, -82.95295, -82.95457, -82.95409, -82.95387, -83.40234, -82.94111, -82.94655, -82.95119, -82.93094, -83.75480, -82.98296, -82.55630, -82.69617, -82.93094, -82.82543, -82.94939, -82.94939, -82.91890, -82.93267, -83.08280, -82.95490, -82.93938, -82.96021, -82.99287))
active_sf <- st_as_sf(active_coordinates, coords = c("Longtitude", "Latitude"), crs = 4326)
## Error in `[.data.frame`(x, coords): undefined columns selected

#Convert data into simple coordinates

tm_shape(active_sf) + tm_dots()
## Error in eval(expr, envir, enclos): object 'active_sf' not found

#Plot recreational activities in Seneca, SC

rec activities in seneca #Plot

#1. I chose Seneca, SC for this assignment because it is my hometown, and I am very familiar with the area. Seneca is surrounded by two lakes, as well as Clemson University, so it lends itself to lots of tourism. I searched for hotels, and recreational activity businesses. #2. There are 36 businesses in total for these 2 categories. #3. There are 8 hotels, and 28 recreational activity businesses. #4. Many of the recreational businesses are located near the lake. Oftentimes, people visit to rent boats, and enjoy a weekend on Lake Keowee. Additionally, many recreational businesses are located in the heart of Downtown Seneca, near the historic “Ram Cat Alley.” This alley is home to a number of businesses, and is a growing hub of activity for Seneca. Additionally, the majority of hotels are located along Highway 123. This highway provides easy access to Clemson University, as well as Interstate I-85.