On 10/30/2013 04:02 AM, palad...@trustindata.de wrote:
Hello,
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.

Hi Claudia,
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":

$names
  [1] "Denmark"
  [2] "USSR"
  [3] "Italy"
  [4] "Netherlands"
  [5] "Iraq"
...

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:

col=c("lightblue","lightred",...)

in the call to map for as many countries as you wanted. Pass NA for those countries that you don't want to color.

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to