map_data {ggplot2} | R Documentation |
Create a data frame of map data.
map_data(map, region = ".", exact = FALSE, ...)
map |
name of map provided by the maps
package. These include |
region |
name of subregions to include. Defaults to
|
exact |
should the |
... |
all other arguments passed on to
|
if (require("maps")) { states <- map_data("state") arrests <- USArrests names(arrests) <- tolower(names(arrests)) arrests$region <- tolower(rownames(USArrests)) choro <- merge(states, arrests, sort = FALSE, by = "region") choro <- choro[order(choro$order), ] qplot(long, lat, data = choro, group = group, fill = assault, geom = "polygon") qplot(long, lat, data = choro, group = group, fill = assault / murder, geom = "polygon") }