Using Leaflet, the map below pinpoints the stadium locations of California’s 16 minor league baseball teams. The map was generated using information provided by Baseball Pilgrimages.
The above map is generated using the following code:
library(leaflet)
#read csv into r
minorParks <- read.csv(file = "parks.csv",
header=TRUE,
as.is = TRUE,
stringsAsFactors = FALSE,
sep = ',')
#the 'head' command is not necessary for the code to work, but here is used to give the user an exploratory feel for the underlying dataframe
head(minorParks, 3)
## City Ballpark.Name Opened Capacity
## 1 Adelanto Heritage Field 1991 3,808
## 2 Bakersfield Sam Lynn Ballpark 1941 2,700
## 3 Fresno Chukchansi Park 2002 12,500
## Home.Team..Affiliate. League.Level
## 1 High Desert Mavericks (Rangers) California/A
## 2 Bakersfield Blaze (Mariners) California/A
## 3 Fresno Grizzlies (Astros) Pacific Coast/AAA
## Address Lat Long
## 1 12000 Stadium Way, Adelanto, CA 92301 34.55503 -117.4021
## 2 4009 Chester Ave, Bakersfield, CA 93301 35.39723 -119.0217
## 3 1800 Tulare St, Fresno, CA 93721 36.73225 -119.7912
minorParks %>%
leaflet() %>%
addTiles() %>%
addMarkers(lat=~Lat, lng=~Long,
clusterOptions = markerClusterOptions(),
popup =~Home.Team..Affiliate.)