library('lehmansociology') library('maps') library("RColorBrewer")
In this template we will use the poverty data to make maps using the maps package. You can also make maps in ggplot2.
To see a nicely formatted copy of this click on the Knit HTML button at the top of this window.
map("usa") map("state") map("county")
data(county.fips)
````
Write your introduction here.
# First we need to load an extra library states_map <- map_data("state")
education_and_poverty$state <- tolower(education_and_poverty$Area_Name) education_and_poverty_map <- merge(states_map, education_and_poverty, by.x = "region", by.y="state")
This actually makes the map, and you an see that this part is very similar to every other ggplot.
# If you want to try colors uncomment the next line and change to the color you want. # Also uncomment the scale_fill_gradientn line. # You can change the color and the number of colors. #colors<-brewer.pal(7,"Greens") ggplot(education_and_poverty_map, aes(x=long, y = lat, group = group, map_id = region, fill = PCTPOVALL_2013)) + geom_map(map = education_and_poverty_map, color = "black" ) + #scale_fill_gradientn(colors=colors) + coord_map("polyconic") + ggtitle("Fig #: ")
Making county level maps
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.