choropleth.county: County level choropleth

View source: R/choropleth.county.R

choropleth.countyR Documentation

County level choropleth

Description

Creates choropleth at the U.S. county level.

Usage

choropleth.county(
  df,
  id.column = "id",
  value.column = "value",
  legend.title = "",
  legend.text.size = 20,
  scale.text.size = 16,
  color.domain = NULL,
  num.legend.ticks = 5,
  color.scheme = c("Blues", names(d3po::color.schemes)),
  width = NULL,
  height = NULL,
  viewer = c("internal", "external", "browser")
)

Arguments

df

data.frame containing value data by county.

id.column

Name of column containing identifiers for states/counties. Defaults to "id". All values in this column must match d3po::us.counties$id.

value.column

Name of column containing values by county. Defaults to "value".

legend.title

Title of legend, e.g., units. Defaults to "".

legend.text.size

Size of text (in points) for legend title. Defaults to 20.

scale.text.size

Size of text (in points) for the scale values. Defaults to 16.

color.domain

Range of values for the color scale. Defaults to c(min(df[,value.column]), max(df[,value.column])). Length greater than two results in a multi-point gradient.

num.legend.ticks

Number of breaks in legend scale. Defaults to 5.

color.scheme

Color scheme to use in visualization. See color.schemes for more details.

width

Desired width for output widget.

height

Desired height for output widget.

viewer

"internal" to use the RStudio internal viewer pane for output; "external" to display in an external RStudio window; "browser" to display in an external browser.

Details

Utilizes a script similar to https://observablehq.com/@d3/choropleth adapted to work with r2d3.

Value

A d3 object as returned by r2d3.

Examples

## Not run: 
data(unemployment.county)

choropleth.county(unemployment.county,
                 id.column = "id",
                 value.column = "rate",
                 legend.title = "Unemployment rate (%)")

## End(Not run)


tkmckenzie/d3po documentation built on June 2, 2022, 2:41 p.m.