Here's a bit of a hacky way to do it:
#get the names of each state state=map('state',plot=F)$names #set up some random state-color data cols = as.data.frame(cbind(state=states,x=sample(1:10,length(states),replace=T))) #do the plot map('usa') for(this_state in state){ map('state',region=this_state,add=T,fill=T,col=cols$x[cols$state==this_state]) } On Thu, Feb 19, 2009 at 12:45 PM, Alina Sheyman <alina...@gmail.com> wrote: > I'm trying to create a colored map that would show the number of students > per state. > My data frame consists of two columns - state and count. > I'm using the following code > > library(maps) > map("usa") > library(plotrix) > state.col<-color.scale(gre$count,0,0,c(0,1)) > map("state",fill=TRUE,col=state.col) > > I'm getting a map, but the values are not being mapped to correct states. > What do I need to do to fix that? > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University www.thatmike.com Looking to arrange a meeting? Check my public calendar: http://www.thatmike.com/mikes-public-calendar ~ Certainty is folly... I think. ~ ______________________________________________ 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.