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.

This shows the outline maps for the US, states and counties.

Make some empty maps (just to show how to do it in the maps package)

map("usa") map("state") map("county")

This loads the fips information from the county map data. Only includes the lower 48 states.

data(county.fips)

````

Introduction

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



SOC345/lehmansociology documentation built on May 9, 2019, 11:41 a.m.