map_data: Create a data frame of map data.

View source: R/fortify-map.r

map_dataR Documentation

Create a data frame of map data.

Description

Create a data frame of map data.

Usage

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

Arguments

map

name of map provided by the 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).

...

all other arguments passed on to map

Examples

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), ]
ggplot(choro, aes(long, lat)) +
  geom_polygon(aes(group = group, fill = assault)) +
  coord_map("albers",  at0 = 45.5, lat1 = 29.5)

ggplot(choro, aes(long, lat)) +
  geom_polygon(aes(group = group, fill = assault / murder)) +
  coord_map("albers",  at0 = 45.5, lat1 = 29.5)
}

animint2 documentation built on Nov. 22, 2023, 1:07 a.m.

Related to map_data in animint2...