This is is not difficult from the online help for the map() function. Here is an example.

map('state', region = c('new york', 'new jersey', 'penn'),fill=TRUE,col=1:4)

There is also an example there in how to add text to the map.

Another way uses the maptools package.

require(maptools)
?plot.Map

and then follow the examples given in the help page for plot.Map().

At 2:42 PM -0700 5/27/05, yyan liu wrote:
Hi:
  I have a question arising from my project.
  A sample of the data is below. The first row stands
for the names of state in USA. The second row stand
for some numeric value in that state. Some of them are
NA. I can use the commands "data(stateMapEnv)" and
"map('state', fill = F)" in library "maps" to make a
plot of USA states. What I want to do is: 1. put the
corresponding state name on the Map 2. give different
state different colors which is related to their
value. For example, "red" for values ranging from
0-30, "green" for values from 80-90, etc. 3. if
possible, put the value of each state within the state
on the map. here, take the numeric value as some text.

Thank you very much!

AB      AK      AL      AR      AZ  CT   CA
91      80      NA      NA      17  33   20

______________________________________________
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


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

______________________________________________
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

Reply via email to