Learn R Programming

usmap (version 0.2.0)

plot_usmap: Conveniently plot basic US map

Description

Conveniently plot basic US map

Usage

plot_usmap(regions = c("states", "state", "counties", "county"),
  include = c(), data = data.frame(), values = "values",
  theme = theme_map(), lines = "black")

Arguments

regions

The region breakdown for the map, can be one of ("states", "state", "counties", "county"). The default is "states".

include

The regions to include in the output data frame. If regions is "states"/"state", the value can be either a state name, abbreviation or FIPS code. For counties, the FIPS must be provided as there can be multiple counties with the same name.

data

A data frame containing values to plot on the map. This parameter should be a data frame consisting of two columns, a fips code (2 characters for state, 5 characters for county) and the value that should be associated with that region. The columns of data _must_ be fips and the value of the `values` parameter.

values

The name of the column that contains the values to be associated with a given region. The default is "value".

theme

The theme that should be used for plotting the map. The default is theme_map.

lines

The line color to be used in the map. Corresponds to the colour option in the aes mapping. The default is "black". Click here for more color options.

Value

A ggplot object that contains a basic US map with the described parameters. Since the result is a ggplot object, it can be extended with more geom layers, scales, labels, themes, etc.

See Also

usmap, theme

Examples

Run this code
# NOT RUN {
plot_usmap()
plot_usmap(regions = "states")
plot_usmap(regions = "counties")
plot_usmap(regions = "state")
plot_usmap(regions = "county")

# Output is ggplot object so it can be extended
# with any number of ggplot layers
library(ggplot2)
plot_usmap(include = c("CA", "NV", "ID", "OR", "WA")) +
  labs(title = "Western States")

# }

Run the code above in your browser using DataLab