Help with Averaging Data per county per state for AQI data... then maps

Oh, okay. I got it!

I tried to copy this website: (https://medium.com/@urban_institute/how-to-create-state-and-county-maps-easily-in-r-577d29300bb2) to map the September AQI differences per county.

install.packages("devtools")
devtools::install_github("UrbanInstitute/urbnmapr")
library(tidyverse)
library(urbnmapr)
library(ggplot2)
SeptWAORDifference %>%
  ggplot(aes(long, lat, group = group, fill = horate)) +
  geom_polygon(color = NA) +
  scale_fill_gradientn(labels = scales::percent,
                       guide = guide_colorbar(title.position = "top")) +
  geom_polygon(data = states, mapping = aes(long, lat, group = group),
               fill = NA, color = "#ffffff") +
  coord_map(projection = "albers", lat0 = 39, lat1 = 45) +
  theme(legend.title = element_text(),
        legend.key.width = unit(.5, "in")) +
  labs(fill = "difference") +
  theme_urban_map()

But I'm met with this error and I'm not sure how to fix it or what to do. I assumed it was from the package but guessing it's not??

Error in theme_urban_map() : could not find function "theme_urban_map"

This is getting a little bit off topic, I think you should open a new topic about your mapping issue (please don't forget the reprex).

The theme shouldn't be your first concern but you need and additional package for that one

devtools::install_github("UI-Research/urbnthemes")
2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.