cranvas (version 0.8.5)

map_qdata: Create data for drawing maps

Description

This function converts maps data in the maps package to a suitable format for cranvas. Optionally it transforms the data to make cartograms.

Usage

map_qdata(database, regions = ".", color = "gray50", border = "gray90", size = 4, cartogram = FALSE, diffuse = 5, label = NULL, ...)

Arguments

database
see map
regions
see map
cartogram
whether to transform the map data in order to create a cartogram; if TRUE, the shape of the cartogram will be determined by the size parameter in the data (i.e. data$.size); see cart_polygon for details
diffuse
passed into cart_polygon. Default to be 5.
...
passed to cart_polygon
color
colors of graphical elements (default dark gray) corresponding to rows of data; it can be a vector of valid R colors, or a name of variable in data (must be either a factor or a numeric variable), or an R expression to calculate colors; color is used to fill the interior of graphical elements
border
colors for the border of graphical elements (e.g. rectangles); NA means to suppress the border
size
sizes of rows; possible values are similar to color, but when using a variable to generate sizes, it must be a numeric variable

Value

A mutaframe of region names and labels, with an attribute MapData containing the coordinates of polygons.

Details

The function map is used to convert maps data to a list, then the region names are stored in a mutaframe created by qdata; the polygon coordinates are stored in an attribute MapData. If multiple polygons belong to the same upper-level region, the column labels will store the upper-level region names.

Examples

Run this code
library(cranvas)
map_qdata("state")
map_qdata("county", "iowa")

Run the code above in your browser using DataLab