[R-sig-Geo] need to create US map with colors by state

Gabor Grothendieck ggrothendieck at gmail.com
Thu Nov 5 20:00:06 CET 2009


Try this:

library(help = maps)

# show polygon names in order
map("state", fill = TRUE, plot = FALSE, names = TRUE)

# make first polygon have color 1, second 2, etc.
map("state", fill = TRUE, col = 1:63)


On Thu, Nov 5, 2009 at 12:14 PM, Mark Kimpel <mwkimpel at gmail.com> wrote:
> I need to do something quite simple, but a search of the "CRAN Task View:
> Analysis of Spatial Data" has not revealed to me the best way to do this.
> What I would like to do is plot a map of the U.S. with each state's color
> corresponding to heatmap colors of a population statistic. For example, dark
> red could be a state with the highest number of H1N1 cases, pink with an
> intermediate number, and white with no cases. An ability to overlay the
> center of the state with the actual statistic would be nice but not
> necessary.
>
> Is there a straightforward method to accomplish this? A vignette perhaps?
>
> Thanks,
>
> Mark
>
> Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
> Indiana University School of Medicine
>
> 15032 Hunter Court, Westfield, IN  46074
>
> (317) 490-5129 Work, & Mobile & VoiceMail
> (317) 399-1219 Skype No Voicemail please
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list