[R] mapping data to a geographic map of Europe
jim at bitwrit.com.au
Tue Oct 29 21:32:02 CET 2013
On 10/30/2013 04:02 AM, paladini at trustindata.de wrote:
> I would like to draw a map of Europe. Each country should be colored
> depending on how it scores in an index called GPIndex.
> Say a dark red for real bad countries a light red for those which are
> not so bad, light blue for the fairly good ones and so on up to the
> really good ones in a dark blue.
> I never worked with geographic maps before so I tried library maps but I
> didn't get far,- especially because all examples I found only seem to
> work for the United states. So I'm a bit lost.
> I would be nice if somebody could help me.
If you draw a map of Europe something like this:
world.map<-map('world', fill = TRUE,
col = 1:10,xlim=c(-15,40),ylim=c(37,70))
you have a "col" argument that you can pass the colors you want. What
you must do is look at the "names" component of "world.map":
to get the indices of the countries. Say Denmark was fairly good, USSR
was fairly bad, and so on. You could then pass colors like this:
in the call to map for as many countries as you wanted. Pass NA for
those countries that you don't want to color.
More information about the R-help