map_data: Create a data frame of map data.

Description Usage Arguments Examples

View source: R/fortify-map.r

Description

Create a data frame of map data.

Usage

1
map_data(map, region=".", exact=FALSE)

Arguments

map

name of map provided by maps package. These include county, france, italy, nz, state, usa, world, world2.

region

name of subregions to include. Defaults to . which includes all subregion. See documentation for map for more details.

exact

should the region be treated as a regular expression (FALSE) or as a fixed string (TRUE).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
require("maps")
require("ggplot2")

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")

hadley/spatialVis documentation built on May 17, 2019, 12:47 p.m.