For reference, here is the code that produced the map:
if (!require("tidyverse"))
install.packages("tidyverse")
if (!require("tidygeocoder"))
install.packages("tidygeocoder")
if (!require("sf"))
install.packages("sf")
if (!require("mapview"))
install.packages("mapview")
if (!require("leaflet"))
install.packages("leaflet")
if (!require("leaflet.extras2"))
install.packages("leaflet.extras2")
if (!require("DataEditR"))
install.packages("DataEditR")
library(tidyverse)
library(tidygeocoder)
library(sf)
library(mapview)
library(leaflet)
library(leaflet.extras2)
library(leafpop)
library(DataEditR)
mapviewOptions(basemaps.color.shuffle = FALSE
)
MyData <- read_csv(
"https://raw.githubusercontent.com/drkblake/Data/refs/heads/main/EarlyVotingRuCo.csv"
)
write_csv(MyData, "EarlyVotingRuCo.csv")
rm(MyData)
Addresses <- read_csv("EarlyVotingRuCo.csv")
Addresses_gc <- Addresses %>%
geocode(Address, method = "census")
Addresses_gc <- data_edit(Addresses_gc)
write_csv(Addresses_gc, "Addresses_gc.csv")
# Convert Addresses_gc to a mappable file
MapData <- st_as_sf(Addresses_gc,
coords = c("long", "lat"),
crs = 4326)
# Make the map
MyMap <- mapview(MapData,
zcol = "Location",
layer.name = "Location",
map.types = c("OpenStreetMap","Esri.WorldImagery"),
popup = popupTable(
MapData,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("Location",
"Address",
"Week",
"Weekend")))
# Show the map
MyMap
Addresses_gc <- Addresses_gc %>%
add_row(Location = "MTSU",
long = -86.361861,
lat = 35.848997) %>%
mutate(Point = case_when(Location == "MTSU" ~ "MTSU", TRUE ~ "Early vote here"))
# Convert Addresses_gc to a mappable file
MapData <- st_as_sf(Addresses_gc,
coords = c("long", "lat"),
crs = 4326)
# Make the map
MyMap <- mapview(MapData,
zcol = "Location",
layer.name = "Location",
map.types = c("OpenStreetMap","Esri.WorldImagery"),
popup = popupTable(
MapData,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("Location",
"Address",
"Week",
"Weekend")))
# Show the map
MyMap
# Convert Addresses_gc to a mappable sf file
MapData <- st_as_sf(Addresses_gc,
coords = c("long", "lat"),
crs = 4326)
# Make the map
MyMap <- mapview(
MapData,
zcol = "Point",
layer.name = "Point",
col.regions = c("orange", "blue"),
map.types = c("OpenStreetMap", "Esri.WorldImagery"),
popup = popupTable(
MapData,
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("Location", "Address", "Week", "Weekend")
)
)
# Show the map
MyMap