[R] Help with maps
h.wickham at gmail.com
Wed Dec 3 01:40:33 CET 2008
On Tue, Dec 2, 2008 at 6:21 PM, Avram Aelony <aavram at mac.com> wrote:
> A few questions about maps...
> (1) How can I find a listing of the internal data sets that map() from the maps library contains?
> For example, "usa", "county", "state", "nz" all work. Are there any others?
help(package = maps)
> (2) Is there an easier, more generalized way to produce this (http://www.ai.rug.nl/~hedderik/R/US2004/ ) type of plot than this (http://www.ai.rug.nl/~hedderik/R/US2004/map.r ) ? I have geographic (e.g. country, state, county, zip code) count data in a data frame that I would like to represent on a map, but still need to study how map.r works, especially the map.center function...
Yes, it's about six lines of ggplot2 code. But a lot depends on the
format of your data, so if you could provide a reproducible example of
what you're trying to do, that would be very helpful.
> (3) The examples at http://had.co.nz/ggplot2/coord_map.html are great. Adding another example that with color codes for counts from a data frame would be very useful too.
qplot(..., colour = count) ?
> (4) Is there a reason why I can produce a map of France but not the UK ?
>>(qplot(x, y, data=(data.frame(map("france", plot=FALSE)[c("x","y")])), geom="path")) + coord_map()
>>(qplot(x, y, data=(data.frame(map("uk", plot=FALSE)[c("x","y")])), geom="path")) + coord_map()
> Error in get(dbname) : variable "ukMapEnv" was not found
> In addition: Warning message:
> In data(list = dbname) : data set 'ukMapEnv' not found
More information about the R-help