library(ggplot2)
library(ggthemes)
library(socviz)
library(maps)
library(mapproj)
library(viridis)
library(tidyverse)
library(tidycensus)
library(leaflet)
library(stringr)
census_api_key("9595e84f199a4490d04d8f6a2e89f64b40cd7c39")Lab 7.1
Looking at the Illinois counties
options(tigris_use_cache = TRUE)
IL_pop <-
get_acs(geography = "county",
variables = "B01003_001",
state = "IL",
geometry = TRUE)Creating a Map of Illinois Counties
MapPalette <- colorQuantile(palette = "plasma", domain = IL_pop$estimate, n = 20)
library(sf)
IL_pop %>%
st_transform(crs = "+proj=longlat +datum=WGS84") %>%
leaflet(width = "100%", height = 500) %>%
addProviderTiles(provider = "Esri.WorldPhysical") %>%
addPolygons(popup = ~NAME,
stroke = FALSE,
smoothFactor = 0,
fillOpacity = 0.7,
color = ~ MapPalette(estimate)) %>%
addLegend("bottomright",
pal = MapPalette,
values = ~ estimate,
title = "Population Percentiles",
opacity = 1) Comments
As expected, there are more Wendy’s locations in the places with the most people. However, there does seem to be a good spread of Wendy’s across all of Illinois, all mostly along highways.
library(leaflet)
library(sf)
# Create a data frame for the Wendy's locations in Chicago
wendys_chicago <- data.frame(
name = c(
"145 S. Western Ave", "1623 W. Division St", "2053 W Lawrence", "2215 N Washtenaw Ave",
"2312 North Ashland", "2350 S Wabash Ave", "242 West Garfield Blvd", "2610 W Pershing",
"317 W Oak St", "3516 E 118th Street", "3610 N Western", "3943 N. Harlem Avenue",
"4100 S. Pulaski Road", "4140 W. Belmont Ave.", "4412 N Pulaski Rd", "4901 W. North Avenue",
"5472 N Harlem Ave", "5679 S. Archer", "5729 S. Kedzie Ave", "6324 N Western Ave",
"7031 South Western Ave", "758 West 117th Street", "7601 South Cicero Avenue", "8302 S Ashland",
"8645 South Stony Island", "8740 S. Lafayette Ave", "9843 S. Western"
),
latitude = c(
41.8788, 41.9039, 41.9681, 41.9191, 41.9234, 41.8479, 41.7944, 41.8191, 41.9000, 41.6860,
41.9469, 41.9482, 41.8157, 41.9386, 41.9564, 41.9115, 41.9794, 41.7928, 41.8046, 41.9957,
41.7579, 41.6806, 41.7491, 41.7445, 41.7433, 41.7293, 41.7343
),
longitude = c(
-87.6868, -87.6727, -87.6888, -87.6970, -87.6668, -87.6252, -87.6317, -87.7018, -87.6359, -87.5538,
-87.6870, -87.8060, -87.7247, -87.7211, -87.7257, -87.7700, -87.7921, -87.7980, -87.7033, -87.6882,
-87.6746, -87.6355, -87.7405, -87.6465, -87.5850, -87.6224, -87.6836
)
)
wendys_colors <- c("white", "#E51837")
wendys_palette <- colorQuantile(
palette = wendys_colors,
domain = IL_pop$estimate,
n = 20
)
IL_pop %>%
st_transform(crs = "+proj=longlat +datum=WGS84") %>%
leaflet(width = "100%", height = 500) %>%
addProviderTiles(provider = "Esri.WorldPhysical") %>%
addPolygons(
popup = ~NAME,
stroke = FALSE,
smoothFactor = 0,
fillOpacity = 0.7,
color = ~wendys_palette(estimate)
) %>%
addLegend(
"bottomright",
pal = wendys_palette,
values = ~estimate,
title = "Population Percentiles",
opacity = 1
) %>%
addCircleMarkers(
data = wendys_il,
lat = ~latitude,
lng = ~longitude,
popup = ~name,
weight = 0.5,
radius = 2,
color = "black",
opacity = 3
) %>%
addMarkers(
data = wendys_chicago,
lat = ~latitude,
lng = ~longitude,
popup = ~name,
label = ~name
) %>%
addTiles() %>%
setView(-89.0, 40.0, zoom = 6.45)Comments
I chose to make the circles black to stand out against the other colors on the map. I chose to use a Wendy’s red and white color to fit with the dataset. I also made the circles a little smaller, so the clump at the top right of Illinois looked a little more uniform. The city of Chicago and those surrounding it contains the most Wendy’s, and then there are a few scattered about the rest of the state.I highlighted the 27 Wendy’s in Chicago, because I felt that was quite an outstanding number of Wendy’s to have in an area.
EDITS
For the final map, I changed the type of map in the background. Instead of a topographical map, there is a road map. Now it is easy to see that many Wendy’s are found major highways or roads.
Comments
This map shows that in the southern part of the state there is less population. Near Lake Michigan is where the higher populated counties are.
Loading Wendy’s Restaurants Locations