I am brand spankin' new when it comes to R. Any help you can give me will be greatly appreciated.
I am using the choroplethr package to create maps by ZIP code. I want to add an overlay showing cities (and only cities), but using reference_map = TRUE
just returns a topographical map with state capitals in additional to making the actual colors harder to differentiate.
Is there a way to append a city overlay onto choroplethr, either with a built-in function of choroplethr that I am overlooking or by combining it with some other package?
My current function is
zip_choropleth(myexcel,
title="Mansfield Geographical Capture by ZCTA",
num_colors=9,
state_zoom = c("massachusetts","rhode island","connecticut"),
reference_map = TRUE)
+ scale_fill_brewer(palette="YlOrRd")
It returns an image like this:
And I want something like this (plus the city overlay!):
This is possible. There are a few things you need to understand in order to accomplish it:
+
operator.Here is demonstration of using geom_point
to to add a black dot for Boston:
library(choroplethrZip)
library(ggplot2)
data(df_pop_zip)
zip_choropleth(df_pop_zip,
state_zoom = c("massachusetts","rhode island","connecticut")) +
geom_point(aes(x=-71.057083, y=42.361145), size=5, color="black")
Note: this just adds a dot. You would have to use something else to add the text. Take a look at the ggplot2 help files for ?geom_label
and ?geom_text
.