#WIC

addr<-read.csv(url("https://raw.githubusercontent.com/coreysparks/data/master/wic_west_side.csv"))
addr<-addr[c(6, 12:14)]
names(addr)<-c("street", "city", "st", "zip")
head(addr)
##                  street        city st   zip
## 1 1039 W Hildebrand Ave San Antonio TX 78201
## 2       1102 Delgado St San Antonio TX 78207
## 3      1115 W Martin St San Antonio TX 78207
## 4      1115 W Martin St San Antonio TX 78207
## 5      1115 W Martin St San Antonio TX 78207
## 6      1115 W Martin St San Antonio TX 78207
library(censusxy)

results<-cxy_geocode(addr,
                     street = "street",
                     city = "city",
                     state ="st",
                     zip = "zip",
                     class="sf",
                     output = "simple")
## Loading required namespace: sf
## 33 rows removed to create an sf object. These were addresses that the geocoder could not match.

#Grocery stores

addr<-read.csv("grocery.csv", header = T)
head(addr)
##          Source       Date Obsolescence.Date                Business.Name
## 1 AtoZDatabases 02/27/2021        08/27/2021                     H-E-B LP
## 2 AtoZDatabases 02/27/2021        08/27/2021                   Dean Foods
## 3 AtoZDatabases 02/27/2021        08/27/2021                Surlean Foods
## 4 AtoZDatabases 02/27/2021        08/27/2021                 Super Target
## 5 AtoZDatabases 02/27/2021        08/27/2021           Botello Food Store
## 6 AtoZDatabases 02/27/2021        08/27/2021 Marios & Brother Corporation
##               Legal.Name                Address        City State   ZIP
## 1 HEB Grocery Company LP        646 S Flores St San Antonio    TX 78204
## 2                        1314 Fredericksburg Rd San Antonio    TX 78201
## 3                             1545 S San Marcos San Antonio    TX 78207
## 4                        4522 Fredericksburg Rd San Antonio    TX 78201
## 5                               1200 El Paso St San Antonio    TX 78207
## 6        Mario's Grocery      2902 Guadalupe St San Antonio    TX 78207
##            Phone          Name                          Title Employee.Size
## 1 (210) 938-8000  Charles Butt        Chief Executive Officer         1,000
## 2 (210) 732-1111  Waly Norwood                 Other Contacts            37
## 3 (210) 227-4370 Travis Holmes Chief Technology Officer Chief           308
## 4 (210) 280-0000                                                        115
## 5 (210) 226-8903  Gladys Lopez                          Owner            40
## 6 (210) 438-1788   Imad Elayna                          Owner            40
##     Revenue...Yr Home.Based.Business Franchise.Type Holding.Parent.Name
## 1 $5,461,426,000                  No                                 NA
## 2    $65,704,000                  No Chain Location                  NA
## 3    $37,381,000                  No                                 NA
## 4    $12,703,000                  No Chain Location                  NA
## 5     $4,855,000                  No                                 NA
## 6     $4,855,000                  No                                 NA
##        Source.1  X
## 1 AtoZDatabases NA
## 2 AtoZDatabases NA
## 3 AtoZDatabases NA
## 4 AtoZDatabases NA
## 5 AtoZDatabases NA
## 6 AtoZDatabases NA
names(addr)
##  [1] "Source"              "Date"                "Obsolescence.Date"  
##  [4] "Business.Name"       "Legal.Name"          "Address"            
##  [7] "City"                "State"               "ZIP"                
## [10] "Phone"               "Name"                "Title"              
## [13] "Employee.Size"       "Revenue...Yr"        "Home.Based.Business"
## [16] "Franchise.Type"      "Holding.Parent.Name" "Source.1"           
## [19] "X"
addr<-addr[c(6:9)]
names(addr)<-c("street", "city", "st", "zip")
head(addr)
##                   street        city st   zip
## 1        646 S Flores St San Antonio TX 78204
## 2 1314 Fredericksburg Rd San Antonio TX 78201
## 3      1545 S San Marcos San Antonio TX 78207
## 4 4522 Fredericksburg Rd San Antonio TX 78201
## 5        1200 El Paso St San Antonio TX 78207
## 6      2902 Guadalupe St San Antonio TX 78207
#install.packages("censusxy")
library(censusxy)

resultsg<-cxy_geocode(addr,
                     street = "street",
                     city = "city",
                     state ="st",
                     zip = "zip",
                     class="sf",
                     output = "simple")
## 18 rows removed to create an sf object. These were addresses that the geocoder could not match.
class(resultsg)
## [1] "sf"         "data.frame"

#Basic interactive map of the points

library(mapview)
## GDAL version >= 3.1.0 | setting mapviewOptions(fgb = TRUE)
#mapview(resultsg, layer.name="Grocery stores", color = "red")+mapview(results, layer.name="WIC #Services", color = "green")
#?mapview