Created
November 12, 2009 20:38
-
-
Save offensivepolitics/233257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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