This is not my finished product. Ultimately, this is the general format of the map that I would like to create, however, I would like to add my poverty rate information for the state of Oregon to the map. I would also like to add mouse-over capabilities so that when you point to a county the name of the county and the poverty rate pop up in a text box. Obviously, this is still a work in progress.
mapOregon = map('county', 'oregon', fill = TRUE, plot = FALSE)
leaflet(data = mapOregon) %>% addTiles() %>%
addPolygons(fillColor = palette(), stroke = TRUE, weight = 2)
When I finish my map this area will be a discussion of the implications of the poverty rate data for Oregon including the surprising observation that Benton County (home of OSU) has one of the higher poverty rates in the state as well as one of the highest median incomes in the state.
In an effort to make the map that I wanted come to life I went to the maps package documentation and checked out the example reproduced here, slighly modified; that is, the example produced a county map of unemployment rates for the entire United States, and I reproduced only the unemployment rate data (from 2009) for Oregon. This looks something like my map will look.
Again, the code below is directly reproduced from the help file with the exception of selecting only Oregon for the map.
# draw map
map("county", "oregon", col = colors[colorsmatched], fill = TRUE, resolution = 0,
lty = 0, projection = "polyconic")
map("state", col = "white", fill = FALSE, add = TRUE, lty = 1, lwd = 0.2,
projection="polyconic")
title("unemployment by county, 2009")
legend("topright", leg.txt, horiz = TRUE, fill = colors)
Since this map worked I tried to duplicate the code with my own data. It was unsuccessful. Here is what my output looked like. I have not figured out what is wrong with it yet.
map("county", "oregon", col = colors[colorsmatched], fill = TRUE, resolution = 0,
lty = 0, projection = "polyconic")
map("state", col = "white", fill = FALSE, add = TRUE, lty = 1, lwd = 0.2,
projection="polyconic")
title("poverty rate by county, 2010")
legend("topright", leg.txt, horiz = TRUE, fill = colors)
Also, I can’t tell most of those pinks apart so I will be changing the color scale. I was just trying to make things work.