[R] creating a map

Greg Snow Greg.Snow at imail.org
Tue Feb 17 18:28:24 CET 2009


You need to give the symbols function the locations where you want the centers of the circles to be.  Some datesets with map information also have centers of the states that you can use, for the USA, there is the state.center dataset that may work for you, or the maptools package function get.Pcent will compute a center for polygons (there are probably other similar functions in other packages).

For adding circles to a map of the USA, you may want to look at the state.vbm data in the TeachingDemos package (works with maptools package), but you will need to computer the centers of the polygons, they don't match state.center or others.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Alina Sheyman
> Sent: Tuesday, February 17, 2009 9:53 AM
> To: r-help at r-project.org
> Subject: [R] creating a map
> 
> I'm trying to create a fairly basic map using R. What i want to get is
> the
> map of the country with circles representing a count of students in
> each
> state.
> What I've done so far is as following -
>   map("state")
> 
> symbols(data1$count,circles=log(data1$count)*3,fg=col,bg=col,add=T,inch
> es=F)
> 
> this gives me the map of the country, but one that's not populated by
> my
> counts.
> Does anyone know what I'm doing wrong?
> 
> Also, if anyone can recommend a good reference for creating maps in R,
> I'd
> really appreciate that.
> 
> thank you
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list