View source: R/choropleth.state.R
choropleth.state | R Documentation |
Creates choropleth at the U.S. state level.
choropleth.state( df, state.column = "state", 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") )
df |
data.frame containing value data by state. |
state.column |
Name of column containing state names. Defaults to "state". All values in this column must match |
value.column |
Name of column containing values by state. Defaults to "value". |
legend.title |
Title of legend, e.g., units. Defaults to "". |
legend.text.size |
Size of text (in points) for legend. 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 |
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. |
Utilizes a script similar to https://observablehq.com/@d3/state-choropleth adapted to work with r2d3.
A d3 object as returned by r2d3.
data(unemployment.state) choropleth.state(unemployment.state, state.column = "name", value.column = "rate", legend.title = "Unemployment rate (%)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.