I have a dataset with some statistics for each ZIP area in the U.S.
I would like to create a map in which each area has a different color based on a statistic, or with some circles showing the density in the zone.
I tried to install the usa package and I used the zipcodes function to create a new table, that I left joined to my dataset by the zipcode. I then wrote this ggplot code:
to_map %>%
ggplot(aes(x = long, y = lat, fill=my_stat)) +
geom_polygon(color = "black", size = 0.09) +
scale_fill_gradient(low = "yellow", high = "dark green") +
ggthemes::theme_map() +
theme(legend.background=element_rect(fill = alpha("white", 0.5)))
But I obtain some weird drawing that makes no sense: enter image description here
Does anyone know how to fix it?