[R] Help with maps

zerfetzen zerfetzen at yahoo.com
Sat Dec 6 22:37:41 CET 2008

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):

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.
View this message in context: http://www.nabble.com/Help-with-maps-tp20804115p20874881.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list