Skip to content
Prev 163962 / 398506 Next

Help with maps

I'm brand new to the map function too, here's my attempt at coloring a map of
the states according to a rate (rather than count):

map('state')$names
MyCount <- c(1:63); MyRate <- runif(63, 0, 1)
map('state', fill=TRUE, col=rgb((1-MyRate),MyRate,0,1))

Seeing that there are 63 "states", means you'll have to adjust your data to
fit.  For example, look at Washington.  I think the effect of MyRate on
color is that as it approaches 1, rgb produces green, and as it approaches
0, rgb produces red.  I know you were asking for counts, but I just had this
handy, and I'm learning too.  Cheers.