Skip to content

Instantly share code, notes, and snippets.

@offensivepolitics
Created November 12, 2009 20:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save offensivepolitics/233257 to your computer and use it in GitHub Desktop.
Save offensivepolitics/233257 to your computer and use it in GitHub Desktop.
library(maps)
unemp <- read.csv('unemployment09.csv',header=FALSE, stringsAsFactors=FALSE,
col.names=c("blsid", "stfips", "cofips", "name", "year", "pop1", "pop2", "unempraw", "unemppct"))
unemp$mpname <- tolower(paste(state.name[match(sub("^.*([A-Z][A-Z])$","\\1",unemp$name,fixed=FALSE),state.abb)],
sub("^(.*) (County|[Cc]ity|Parish), ..$","\\1", unemp$name),sep=","))
unemp$ri <- as.numeric(cut(unemp$unemppct,c(seq(0,10,by=2),max(unemp$unemppct))))
cols <- c("#F1EEF6", "#D4B9DA", "#C994C7", "#DF65B0", "#DD1C77", "#980043")
mp <- map("county", plot=FALSE,namesonly=TRUE)
map("county", col=cols[unemp[match(mp,unemp$mpname),]$ri],fill=TRUE)
@m-a-j
Copy link

m-a-j commented Jul 20, 2013

Hi.

I came across this page via the chloropleth challenge page. I've not yet understood all of the code above, but as you surely put a lot of effort into the challenge, I'd still like to ask you one question:
In the meantime, have you found one package that was particularly useful for displaying (and generally working with) maps in R? Or have you spent more time on developping your own maps-related projects?
I'm asking because I'd like to work with maps in the near future and I'm still not sure which package to use.

Cheers,
Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment