Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Choropleths in R
#load data
stateAbbr rownames(stateAbbr)unemp_data
#get county names in correct format
countyNames counties statesstates
#concatenate states and counties
#parse out county titles & specifics
unemp_data$counties unemp_data$counties unemp_data$countiesunemp_data$counties
#define color buckets
colors = c("#F1EEF6", "#D4B9DA", "#C994C7", "#DF65B0", "#DD1C77", "#980043")
#align data with map definitions
#draw map
map("county",col = colors[unemp_data$colorBuckets[match(mapnames ,unemp_data$counties)]],
fill = TRUE,resolution = 0,lty = 0,projection = "polyconic")
map("state",col = "white",fill=FALSE,add=TRUE,lty=1,lwd=1,projection="polyconic")

This comment has been minimized.

Copy link
Owner Author

reubano commented Oct 12, 2011


“state abbr.csv” is a simple file I created to provide a mapping between state names and state abbreviations — as I recall, the data format and the necessary format in R were not the same. The file looked like this: New Jersey | NJ || New Mexico | NM || New York | NY ||

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.