airports <- read_csv("~/Documents/ide-workspace/R/COMP 112/Midterm-Choropleth Map/airports.csv")
## Rows: 19615 Columns: 14
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (13): state, region, ado, city, county, facility_name, ownership, use, ...
## date (1): effective_date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mnAirports <- airports %>%
filter(state == "MN") %>%
select(county, facility_name)
mnAirports2 <- mnAirports %>%
group_by(county) %>%
summarize(perCountyAirports = n())
mnAirports <- mnAirports %>%
left_join(mnAirports2) %>%
mutate(county = tolower(county)) %>%
mutate(county = str_to_title(county))
## Joining with `by = join_by(county)`
mnAirportsFinal <- mnAirports %>%
select(county, perCountyAirports) %>%
rename("NAME" = "county")
mnCounties <- read_sf("~/Documents/ide-workspace/R/COMP 112/Midterm-Choropleth Map/mnCounties", "county2010")
mnCounties <- mnCounties %>%
left_join(mnAirportsFinal)
## Joining with `by = join_by(NAME)`
pdf("/Users/ben/Documents/ide-workspace/R/COMP 112/Midterm-Choropleth Map/choropleth.pdf",
width = 10,
height = 10)
ggplot() +
geom_sf(data = mnCounties, aes(fill = perCountyAirports), color='transparent') +
geom_sf(data = mnCounties, fill='transparent', color = 'white') +
scale_fill_viridis_b() +
labs(fill = "Number of airports in the county")
dev.off()
## quartz_off_screen
## 2