I'm trying to create a world map and color certain nations. Basically, I would like to highlight some countries in red and other countries in blue.
If someone could help me generate the basic [R] code for this, I would be very thankful!!
I'm trying to create a world map and color certain nations. Basically, I would like to highlight some countries in red and other countries in blue.
If someone could help me generate the basic [R] code for this, I would be very thankful!!
If you are not hooked on using the
maps
package, the objectwrld_simpl
in themaptools
package can make producing this sort of map pretty easy. Here, to get you started, are a few lines of code that produce a world map in which nations whose names start with the letter "U" are colored in red:(
wrld_simpl
is an object of classSpatialPolygonsDataFrame
, and the data.frame contained inwrld_simple@data
includes aNAME
column that you can use to highlight whichever countries you choose.)