R Markdown

library(readxl)
addr<-read_xls("Food_Stores_WS.xls")
## New names:
## * Source -> Source...1
## * Source -> Source...18
addr<-addr[c(6, 7:10)]
names(addr)<-c("street", "city", "st", "zip")
## Warning: The `value` argument of ``names<-`()` must have the same length as `x` as of tibble 3.0.0.
## `names` must have length 5, not 4.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Warning: The `value` argument of ``names<-`()` can't be empty as of tibble 3.0.0.
## Column 5 must be named.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
head(addr)
## # A tibble: 6 x 5
##   street                 city        st    zip   NA            
##   <chr>                  <chr>       <chr> <chr> <chr>         
## 1 646 S Flores St        San Antonio TX    78204 (210) 938-8000
## 2 1314 Fredericksburg Rd San Antonio TX    78201 (210) 732-1111
## 3 1545 S San Marcos      San Antonio TX    78207 (210) 227-4370
## 4 4522 Fredericksburg Rd San Antonio TX    78201 (210) 280-0000
## 5 1200 El Paso St        San Antonio TX    78207 (210) 226-8903
## 6 2902 Guadalupe St      San Antonio TX    78207 (210) 438-1788
summary(addr)
##     street              city                st                zip           
##  Length:59          Length:59          Length:59          Length:59         
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##       NA           
##  Length:59         
##  Class :character  
##  Mode  :character
library(censusxy)
## Warning: package 'censusxy' was built under R version 4.0.4
results<-cxy_geocode(addr,
                     street = "street",
                     city = "city",
                     state ="st",
                     zip = "zip",
                     class="sf",
                     output = "simple")
## Loading required namespace: sf
## 21 rows removed to create an sf object. These were addresses that the geocoder could not match.
results<-results[, -5]

library(mapview)
mapview::mapview(results, layer.name="Grocery Stores on the Westside")
32/59
## [1] 0.5423729

54% of grocery stores were correctly geocoded.

library(readxl)
addr<-read_xls("WIC_WS.xls")
## New names:
## * Source -> Source...1
## * Source -> Source...18
addr<-addr[c(6, 7:9)]
names(addr)<-c("street", "city", "st", "zip")
head(addr)
## # A tibble: 6 x 4
##   street                         city        st    zip  
##   <chr>                          <chr>       <chr> <chr>
## 1 6800 W Interstate 10 Ste 200   San Antonio TX    78201
## 2 1410 Guadalupe St Ste 222      San Antonio TX    78207
## 3 527 N Leona St                 San Antonio TX    78207
## 4 1131 Babcock Rd Ste 125        San Antonio TX    78201
## 5 4522 Fredericksburg Rd Ste A45 San Antonio TX    78201
## 6 121 S Leona St                 San Antonio TX    78207
summary(addr)
##     street              city                st                zip           
##  Length:102         Length:102         Length:102         Length:102        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character
library(censusxy)
results<-cxy_geocode(addr,
                     street = "street",
                     city = "city",
                     state ="st",
                     zip = "zip",
                     class="sf",
                     output = "simple")
## 21 rows removed to create an sf object. These were addresses that the geocoder could not match.
results2<-results[, -5]

library(mapview)
mapview::mapview(results2, layer.name="WIC Services on the Westside")
81/102
## [1] 0.7941176

79% of WIC offices were correctly geocoded.

mapview::mapview(list(results, results2), layer.name= c("Grocery Stores on the Westside","WIC Services  on the Westside"))