[R] Statistical data and Map-package

From: Rense Nieuwenhuis <R.Nieuwenhuis_at_student.ru.nl>
Date: Tue 26 Sep 2006 - 08:21:24 GMT


Dear helpeRs,

I'm working with the map-package and came upon a problem which I couldn't solve. I hope onee of you can. If not, this can be seen as a suggestion for new versions of the package.

I'm trying to create a map of some European countries, filled with colors corresponding to some values. Let's say I have the following countries and I assign the following colors (fictional):

country2001 <- c("Austria", "Belgium", "Switzerland",
"Czechoslovakia", "Germany", "Denmark", "Spain", "Finland", "France",
"UK", "Greece", "Hungary", "Ireland", "Israel", "Italy",
"Luxembourg", "Netherlands", "Norway", "Poland", "Portugal",

"Sweden", "Slovenia")

color2001 <- c("green", "yellow","red","red", "red", "red", "red",
"red", "green", "red", "red", "red", "red", "red", "red", "red",
"red", "blue", "red", "red", "red", "orange")

I then let the colors and the values correspond using 'match.map', like this:

match <- match.map("world",country2001)
color <- color2001[match]

And finally I plot the map. It works perfectly fine.

map(database="world", fill=TRUE, col=color)

But as I mentioned, I want to create a map of Europe. So, I use xlim and ylim to let some parts of the world fall of the map. The syntax becomes like this:

map(database="world", fill=TRUE, col=color, xlim=c(-25,70),ylim=c (35,71))

Now, a problem arises. The regions on the map are colored by the vector 'color'. It needs therefore to correspond to the order in which the polygons are drawn. Since some of the full world-map isn't drawn this time, the color-vector doesn't correspond anymore. This results in the coloring of the wrong countries.

Does anybody know of a way to solve this?

Thanks very much in advance,

Rense Nieuwenhuis

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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. Received on Tue Sep 26 18:42:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 26 Sep 2006 - 09:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.