diff --git a/DESCRIPTION b/DESCRIPTION
index 5d1d52f..1277497 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -26,3 +26,12 @@ Imports:
ggplot2 (>= 2.2.0),
scales (>= 0.5.0)
RoxygenNote: 6.0.1
+Collate:
+ 'aaa.R'
+ 'geom-rrect.r'
+ 'geom-rtile.R'
+ 'gutil.R'
+ 'statebins-package.R'
+ 'statebins.R'
+ 'theme-statebin.R'
+ 'util.R'
diff --git a/NAMESPACE b/NAMESPACE
index afca8a1..503adee 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -2,10 +2,14 @@
export(statebins)
export(theme_statebins)
+importFrom(ggplot2,Geom)
+importFrom(ggplot2,GeomRect)
+importFrom(ggplot2,Stat)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,coord_equal)
+importFrom(ggplot2,draw_key_polygon)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_rect)
importFrom(ggplot2,element_text)
@@ -14,15 +18,18 @@ importFrom(ggplot2,geom_text)
importFrom(ggplot2,geom_tile)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggplotGrob)
+importFrom(ggplot2,ggproto)
importFrom(ggplot2,ggtitle)
importFrom(ggplot2,guides)
importFrom(ggplot2,labs)
+importFrom(ggplot2,layer)
importFrom(ggplot2,rel)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_fill_brewer)
importFrom(ggplot2,scale_fill_manual)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_y_continuous)
+importFrom(ggplot2,scale_y_reverse)
importFrom(ggplot2,theme)
importFrom(ggplot2,theme_bw)
importFrom(scales,alpha)
diff --git a/NEWS.md b/NEWS.md
index 42a57a2..7dc90ee 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
* Added support for `VI`/`Virgin Islands`
* Supports auto-computation of when to use light & dark label colors
* New `theme_statebins()`
+* Rounded rectangle support!
* Completely re-designed the interface and will not be providing backwards-compatibility.
# statebins 1.2.2
diff --git a/R/geom-rrect.r b/R/geom-rrect.r
new file mode 100644
index 0000000..f97b35c
--- /dev/null
+++ b/R/geom-rrect.r
@@ -0,0 +1,52 @@
+geom_rrect <- function(mapping = NULL, data = NULL,
+ stat = "identity", position = "identity",
+ ...,
+ na.rm = FALSE,
+ show.legend = NA,
+ inherit.aes = TRUE) {
+ layer(
+ data = data,
+ mapping = mapping,
+ stat = stat,
+ geom = GeomRect,
+ position = position,
+ show.legend = show.legend,
+ inherit.aes = inherit.aes,
+ params = list(
+ na.rm = na.rm,
+ ...
+ )
+ )
+}
+
+GeomRrect <- ggplot2::ggproto("GeomRrect", ggplot2::Geom,
+ default_aes = aes(colour = NA, fill = "grey35", size = 0.5, linetype = 1,
+ alpha = NA),
+
+ required_aes = c("xmin", "xmax", "ymin", "ymax"),
+
+ draw_panel = function(self, data, panel_params, coord) {
+ coords <- coord$transform(data, panel_params)
+ lapply(1:length(coords$xmin), function(i) {
+ ggname("geom_rrect", grid::roundrectGrob(
+ coords$xmin[i], coords$ymax[i],
+ width = (coords$xmax[i] - coords$xmin[i]),
+ height = (coords$ymax[i] - coords$ymin)[i],
+ r=unit(0.3, "snpc"),
+ default.units = "native",
+ just = c("left", "top"),
+ gp = grid::gpar(
+ col = coords$colour[i],
+ fill = alpha(coords$fill[i], coords$alpha[i]),
+ lwd = coords$size[i] * .pt,
+ lty = coords$linetype[i],
+ lineend = "butt"
+ )
+ ))
+ }) -> gl
+
+ do.call(grid::gList, gl)
+ },
+
+ draw_key = ggplot2::draw_key_polygon
+)
\ No newline at end of file
diff --git a/R/geom-rtile.R b/R/geom-rtile.R
new file mode 100644
index 0000000..576d45e
--- /dev/null
+++ b/R/geom-rtile.R
@@ -0,0 +1,41 @@
+geom_rtile <- function(mapping = NULL, data = NULL,
+ stat = "identity", position = "identity",
+ ...,
+ na.rm = FALSE,
+ show.legend = NA,
+ inherit.aes = TRUE) {
+ layer(
+ data = data,
+ mapping = mapping,
+ stat = stat,
+ geom = GeomRtile,
+ position = position,
+ show.legend = show.legend,
+ inherit.aes = inherit.aes,
+ params = list(
+ na.rm = na.rm,
+ ...
+ )
+ )
+}
+
+GeomRtile <- ggplot2::ggproto("GeomRtile", GeomRrect,
+ extra_params = c("na.rm", "width", "height"),
+
+ setup_data = function(data, params) {
+ data$width <- data$width %||% params$width %||% resolution(data$x, FALSE)
+ data$height <- data$height %||% params$height %||% resolution(data$y, FALSE)
+
+ transform(data,
+ xmin = x - width / 2, xmax = x + width / 2, width = NULL,
+ ymin = y - height / 2, ymax = y + height / 2, height = NULL
+ )
+ },
+
+ default_aes = aes(fill = "grey20", colour = NA, size = 0.1, linetype = 1,
+ alpha = NA),
+
+ required_aes = c("x", "y"),
+
+ draw_key = ggplot2::draw_key_polygon
+)
diff --git a/R/gutil.R b/R/gutil.R
new file mode 100644
index 0000000..7401d15
--- /dev/null
+++ b/R/gutil.R
@@ -0,0 +1,8 @@
+# Name ggplot grid object
+# Convenience function to name grid objects
+#
+# @keyword internal
+ggname <- function(prefix, grob) {
+ grob$name <- grid::grobName(grob, prefix)
+ grob
+}
diff --git a/R/statebins-package.R b/R/statebins-package.R
index a3ab5c8..2d6ee83 100644
--- a/R/statebins-package.R
+++ b/R/statebins-package.R
@@ -9,6 +9,6 @@
#' @importFrom ggplot2 geom_point geom_text scale_color_manual guides theme labs
#' @importFrom ggplot2 scale_x_continuous scale_y_continuous coord_equal theme_bw
#' @importFrom ggplot2 aes element_rect element_blank element_text
-#' @importFrom ggplot2 aes_string aes_
-#' @importFrom ggplot2 scale_fill_brewer ggtitle rel
+#' @importFrom ggplot2 aes_string aes_ scale_y_reverse layer GeomRect
+#' @importFrom ggplot2 scale_fill_brewer ggtitle rel ggproto draw_key_polygon Geom Stat
NULL
diff --git a/R/statebins.R b/R/statebins.R
index e5555ce..5395b25 100644
--- a/R/statebins.R
+++ b/R/statebins.R
@@ -27,8 +27,10 @@
#' @param font_size font size (default = \code{3})
#' @param state_border_col default "\code{white}" - this creates the "spaces" between boxes
#' @param state_border_size border size
+#' @param round rounded corners (default: `FALSE`)
#' @param ggplot2_scale_function ggplot2 scale function to use. Defaults to `scale_fill_distiller`
#' since you're likely passing in continuous data when you shouldn't be :-)
+#' @param ... additional parameters to the scale function
#' @return ggplot2 object
#' @export
#' @examples
@@ -41,6 +43,7 @@ statebins <- function(state_data,
state_col="state", value_col="value",
dark_label = "black", light_label = "white", font_size=3,
state_border_col="white", state_border_size=2,
+ round = FALSE,
ggplot2_scale_function=ggplot2::scale_fill_distiller,
...) {
@@ -58,9 +61,17 @@ statebins <- function(state_data,
sort=TRUE)
gg <- ggplot()
- gg <- gg + geom_tile(data = st.dat,
- aes_string(x = "col", y = "row", fill = value_col),
- color = state_border_col, size = state_border_size)
+
+ if (round) {
+ gg <- gg + geom_rtile(data = st.dat,
+ aes_string(x = "col", y = "row", fill = value_col),
+ color = state_border_col, size = state_border_size)
+ } else {
+ gg <- gg + geom_tile(data = st.dat,
+ aes_string(x = "col", y = "row", fill = value_col),
+ color = state_border_col, size = state_border_size)
+ }
+
gg <- gg + scale_y_reverse()
gg <- gg + ggplot2_scale_function(...)
gg <- gg + coord_equal()
diff --git a/README.Rmd b/README.Rmd
index 003d02c..bcf3c6d 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -38,7 +38,7 @@ packageVersion("statebins")
# the original wapo data
-adat <- suppressMessages(read_csv("http://www.washingtonpost.com/wp-srv/special/business/states-most-threatened-by-trade/states.csv?cache=1"))
+adat <- suppressMessages(read_csv(system.file("extdata", "wapostates.csv", package="statebins")))
mutate(
adat,
@@ -73,7 +73,7 @@ statebins(adat, value_col = "avgshare08_12", palette = "Purples") +
# mortality data (has Puerto Rico)
# from: http://www.cdc.gov/nchs/fastats/state-and-territorial-data.htm
-dat <- suppressMessages(read_csv("http://datadrivensecurity.info/data/deaths.csv"))
+dat <- suppressMessages(read_csv(system.file("extdata", "deaths.csv", package="statebins")))
statebins(dat, value_col = "death_rate", name="Per 100K pop") +
labs(title="Mortality Rate (2010)") +
@@ -87,7 +87,7 @@ statebins(dat, value_col="fertility_rate", name="Per 100K pop", palette="PuBuGn"
# manual - perhaps good for elections?
-election_2012 <- suppressMessages(read_csv("https://raw.githubusercontent.com/hrbrmstr/statebins/master/tmp/election2012.csv"))
+election_2012 <- suppressMessages(read_csv(system.file("extdata", "election2012.csv", package="statebins")))
mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
statebins(
@@ -99,6 +99,17 @@ mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
theme_statebins()
```
+### Rounded rects!
+
+```{r}
+
+data(USArrests)
+
+USArrests$state <- rownames(USArrests)
+statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE) +
+ theme_statebins(legend_position="right")
+```
+
### All the "states"
`statebins` now has PR, VI & NYC (by name or abbreviation) so you can use them, too:
diff --git a/README.md b/README.md
index 4db6670..8dac271 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ packageVersion("statebins")
``` r
# the original wapo data
-adat <- suppressMessages(read_csv("http://www.washingtonpost.com/wp-srv/special/business/states-most-threatened-by-trade/states.csv?cache=1"))
+adat <- suppressMessages(read_csv(system.file("extdata", "wapostates.csv", package="statebins")))
mutate(
adat,
@@ -83,7 +83,7 @@ statebins(adat, value_col = "avgshare08_12", palette = "Purples") +
# mortality data (has Puerto Rico)
# from: http://www.cdc.gov/nchs/fastats/state-and-territorial-data.htm
-dat <- suppressMessages(read_csv("http://datadrivensecurity.info/data/deaths.csv"))
+dat <- suppressMessages(read_csv(system.file("extdata", "deaths.csv", package="statebins")))
statebins(dat, value_col = "death_rate", name="Per 100K pop") +
labs(title="Mortality Rate (2010)") +
@@ -105,7 +105,7 @@ statebins(dat, value_col="fertility_rate", name="Per 100K pop", palette="PuBuGn"
``` r
# manual - perhaps good for elections?
-election_2012 <- suppressMessages(read_csv("https://raw.githubusercontent.com/hrbrmstr/statebins/master/tmp/election2012.csv"))
+election_2012 <- suppressMessages(read_csv(system.file("extdata", "election2012.csv", package="statebins")))
mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
statebins(
@@ -119,6 +119,18 @@ mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
+### Rounded rects\!
+
+``` r
+data(USArrests)
+
+USArrests$state <- rownames(USArrests)
+statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE) +
+ theme_statebins(legend_position="right")
+```
+
+
+
### All the “states”
`statebins` now has PR, VI & NYC (by name or abbreviation) so you can
@@ -150,4 +162,4 @@ statebins(us_arrests, value_col="Assault",
theme_statebins("right")
```
-
+
diff --git a/README_files/figure-gfm/unnamed-chunk-4-1.png b/README_files/figure-gfm/unnamed-chunk-4-1.png
index f2e2fc5..64bfa3e 100644
Binary files a/README_files/figure-gfm/unnamed-chunk-4-1.png and b/README_files/figure-gfm/unnamed-chunk-4-1.png differ
diff --git a/README_files/figure-gfm/unnamed-chunk-5-1.png b/README_files/figure-gfm/unnamed-chunk-5-1.png
new file mode 100644
index 0000000..f2e2fc5
Binary files /dev/null and b/README_files/figure-gfm/unnamed-chunk-5-1.png differ
diff --git a/_README_files/figure-markdown_github/unnamed-chunk-31.png b/_README_files/figure-markdown_github/unnamed-chunk-31.png
deleted file mode 100644
index 6cb9d36..0000000
Binary files a/_README_files/figure-markdown_github/unnamed-chunk-31.png and /dev/null differ
diff --git a/_README_files/figure-markdown_github/unnamed-chunk-32.png b/_README_files/figure-markdown_github/unnamed-chunk-32.png
deleted file mode 100644
index 5200b01..0000000
Binary files a/_README_files/figure-markdown_github/unnamed-chunk-32.png and /dev/null differ
diff --git a/_README_files/figure-markdown_github/unnamed-chunk-33.png b/_README_files/figure-markdown_github/unnamed-chunk-33.png
deleted file mode 100644
index 55b4246..0000000
Binary files a/_README_files/figure-markdown_github/unnamed-chunk-33.png and /dev/null differ
diff --git a/inst/extdata/deaths.csv b/inst/extdata/deaths.csv
new file mode 100644
index 0000000..f6cf9da
--- /dev/null
+++ b/inst/extdata/deaths.csv
@@ -0,0 +1,54 @@
+state,births,fertility_rate,deaths,death_rate
+Alabama,58448,60.9,48681,1013.6
+Alaska,11187,75.9,3849,532.6
+Arizona,86441,67.5,48381,746.3
+Arkansas,38347,67.0,29653,1009.3
+California,503755,63.3,239942,636.6
+Colorado,65187,62.0,32563,636.4
+Connecticut,36359,53.2,29526,824.6
+Delaware,11023,61.4,7845,864.8
+District of Columbia,9399,55.3,4589,742.6
+Florida,213148,59.0,173976,912.9
+Georgia,130280,62.4,71248,725.9
+Hawaii,18980,71.6,9923,721.8
+Idaho,22963,74.1,12027,758.8
+Illinois,159160,60.9,101906,791.9
+Indiana,83227,64.7,58202,893.1
+Iowa,38702,66.8,28184,920.4
+Kansas,40341,72.3,25116,874.7
+Kentucky,55758,65.4,42626,975.6
+Louisiana,62642,67.0,40890,893.8
+Maine,12798,53.9,13007,978.9
+Maryland,72883,60.8,43745,750.6
+Massachusetts,72439,53.5,53710,815.3
+Michigan,113091,59.6,89508,906.3
+Minnesota,68772,65.7,39820,745.0
+Mississippi,38669,64.2,29278,983.0
+Missouri,75446,64.3,55848,929.1
+Montana,12118,66.6,9115,913.1
+Nebraska,25942,72.3,15476,839.9
+Nevada,34911,63.0,20343,747.0
+New Hampshire,12352,50.3,10823,821.0
+New Jersey,104230,60.4,70558,799.9
+New Mexico,27068,67.8,16452,790.1
+New York,240916,59.7,149174,766.4
+North Carolina,119831,61.0,79882,827.2
+North Dakota,10106,74.6,5965,872.2
+Ohio,138483,62.6,111427,965.2
+Oklahoma,52751,70.5,37175,980.5
+Oregon,45067,59.0,32788,846.8
+Pennsylvania,142514,58.8,128237,1006.3
+Rhode Island,10926,51.7,9581,911.3
+South Carolina,57155,61.4,42072,899.1
+South Dakota,12104,78.1,7314,887.5
+Tennessee,80371,62.6,60541,945.5
+Texas,382727,69.9,168640,656.8
+Utah,51465,83.1,15266,541.9
+Vermont,6009,51.6,5433,867.3
+Virginia,103013,61.7,60804,751.0
+Washington,87463,63.5,49691,727.5
+West Virginia,20827,61.3,21867,1178.6
+Wisconsin,67295,61.8,48410,847.5
+Wyoming,7572,69.5,4387,772.1
+Puerto Rico,38900,51.8,29758,802.8
+
diff --git a/inst/extdata/election2012.csv b/inst/extdata/election2012.csv
new file mode 100644
index 0000000..f7cbd4d
--- /dev/null
+++ b/inst/extdata/election2012.csv
@@ -0,0 +1,52 @@
+state,Obama,Romney
+AL,,9
+AK,,3
+AZ,,11
+AR,,6
+CA,55,
+CO,9,
+CT,7,
+DE,3,
+DC,3,
+FL,29,
+GA,,16
+HI,4,
+ID,,4
+IL,20,
+IN,,11
+IA,6,
+KS,,6
+KY,,8
+LA,,8
+ME,4,
+MD,10,
+MA,11,
+MI,16,
+MN,10,
+MS,,6
+MO,,10
+MT,,3
+NE,,5
+NV,6,
+NH,4,
+NJ,14,
+NM,5,
+NY,29,
+NC,,15
+ND,,3
+OH,18,
+OK,,7
+OR,7,
+PA,20,
+RI,4,
+SC,,9
+SD,,3
+TN,,11
+TX,,38
+UT,,6
+VT,3,
+VA,13,
+WA,12,
+WV,,5
+WI,10,
+WY,,3
\ No newline at end of file
diff --git a/inst/extdata/wapostates.csv b/inst/extdata/wapostates.csv
new file mode 100644
index 0000000..1ec7cdd
--- /dev/null
+++ b/inst/extdata/wapostates.csv
@@ -0,0 +1 @@
+fipst,stab,state,workers1994,workers1995,workers1996,workers1997,workers1998,workers1999,workers2000,workers2001,workers2002,workers2003,workers2004,workers2005,workers2006,workers2007,workers2008,workers2009,workers2010,workers2011,workers2012,workers2013,share_cut1994,share_cut1995,share_cut1996,share_cut1997,share_cut1998,share_cut1999,share_cut2000,share_cut2001,share_cut2002,share_cut2003,share_cut2004,share_cut2005,share_cut2006,share_cut2007,share_cut2008,share_cut2009,share_cut2010,share_cut2011,share_cut2012,share_cut2013,avgshare,avgshare94_00,avgshare01_07,avgshare08_12
37,NC,North Carolina,3831,2631,8716,12324,9428,12414,4790,12596,19564,21126,11435,13167,10602,14815,11767,11533,12746,4120,2953,3301,1.4,0.9,3.0,4.1,3.0,3.9,1.5,3.8,6.1,6.7,3.6,4.1,3.2,4.3,3.4,3.5,4.1,1.3,0.9,1.0,3.56,2.53,4.56,2.64
01,AL,Alabama,1504,3527,7627,6858,5340,8697,3919,4400,9895,3285,3156,1895,5358,4156,6377,6661,5306,571,1033,834,1.1,2.4,5.2,4.6,3.5,5.6,2.5,2.8,6.5,2.2,2.1,1.2,3.3,2.6,3.9,4.3,3.6,0.4,0.7,0.6,3.22,3.55,2.95,2.58
28,MS,Mississippi,1613,3344,4454,1938,3108,6143,2839,3292,4796,3785,1350,1345,1807,2246,3366,3262,473,77,386,226,2.0,3.9,5.1,2.2,3.4,6.7,3.1,3.6,5.4,4.3,1.5,1.5,2.0,2.5,3.7,3.7,0.6,0.1,0.5,0.3,2.94,3.77,2.99,1.71
05,AR,Arkansas,1376,1107,1473,2426,2559,2653,604,3041,3741,3417,1093,2223,3781,4905,3220,2891,3088,2239,3769,507,1.6,1.3,1.6,2.7,2.7,2.8,0.6,3.1,3.9,3.6,1.1,2.3,3.8,4.9,3.2,3.0,3.3,2.4,3.9,0.5,2.89,1.91,3.27,3.16
47,TN,Tennessee,3210,4149,7297,7544,7435,5706,5107,7104,8137,7528,2673,6156,4849,8254,7262,7647,7938,7100,2108,2606,1.6,2.0,3.4,3.5,3.3,2.5,2.2,3.1,3.6,3.3,1.2,2.7,2.1,3.5,3.0,3.4,3.7,3.2,0.9,1.1,2.86,2.64,2.77,2.85
45,SC,South Carolina,1991,1289,3422,975,3922,1739,2427,6296,6585,5690,4623,5913,5270,3473,4479,5846,2575,1513,1864,1321,1.5,1.0,2.5,0.7,2.7,1.2,1.6,4.1,4.5,3.9,3.1,3.9,3.4,2.2,2.8,3.9,1.8,1.0,1.2,0.9,2.61,1.60,3.57,2.14
23,ME,Maine,971,855,1540,792,2358,742,1091,1683,2486,2353,870,602,678,576,1591,1551,1162,1128,352,763,2.3,1.9,3.5,1.7,5.0,1.5,2.2,3.3,5.0,4.7,1.7,1.2,1.3,1.1,3.1,3.1,2.4,2.3,0.7,1.5,2.58,2.59,2.61,2.31
26,MI,Michigan,932,1388,4036,3491,2011,2343,7113,3102,7809,11947,5610,5142,9401,14224,15434,25782,29822,3817,1718,2977,0.3,0.4,1.1,0.9,0.5,0.6,1.8,0.8,2.1,3.2,1.5,1.4,2.5,3.9,4.3,7.8,9.3,1.2,0.5,0.9,2.55,0.80,2.20,4.62
41,OR,Oregon,426,760,1608,976,2390,1364,4912,2090,7802,3310,4713,1350,1054,1523,3224,9457,4543,1430,1775,2048,0.4,0.7,1.3,0.8,1.9,1.0,3.7,1.5,6.0,2.5,3.6,1.0,0.8,1.1,2.2,7.0,3.5,1.1,1.3,1.5,2.38,1.39,2.37,3.03
21,KY,Kentucky,3222,1334,4299,2560,2126,3884,2801,3621,4271,3568,2294,3171,2307,3716,3357,5805,4557,2163,1649,971,2.5,1.0,3.1,1.8,1.5,2.6,1.8,2.4,2.9,2.4,1.6,2.1,1.5,2.4,2.2,3.9,3.2,1.5,1.1,0.6,2.24,2.06,2.19,2.38
18,IN,Indiana,850,1685,2598,3634,3071,2933,1943,3220,10193,5972,4705,5821,5473,5145,8908,7503,10017,3804,2178,1733,0.4,0.7,1.1,1.5,1.2,1.2,0.7,1.3,4.1,2.4,1.9,2.3,2.1,2.0,3.5,3.1,4.3,1.6,0.9,0.7,2.07,0.97,2.30,2.67
02,AK,Alaska,614,100,250,500,261,1684,42,0,260,2843,230,484,,140,0,3,0,0,,95,3.4,0.5,1.3,2.6,1.3,8.3,0.2,0.0,1.2,13.2,1.0,2.1,0.0,0.6,0.0,0.0,0.0,0.0,0.0,0.4,1.88,2.52,2.60,0.00
42,PA,Pennsylvania,6690,6411,8959,7831,6922,6340,6812,17945,13839,13851,5746,7358,4691,8292,5030,13046,11882,4639,5288,4245,1.5,1.4,2.0,1.7,1.5,1.3,1.4,3.6,2.8,2.8,1.2,1.5,0.9,1.6,1.0,2.6,2.5,0.9,1.1,0.8,1.79,1.53,2.07,1.62
55,WI,Wisconsin,1769,1932,3560,1308,1256,4449,2066,4508,6343,7143,3041,2602,3320,3295,5063,7125,8268,3567,2777,949,0.8,0.9,1.6,0.6,0.5,1.9,0.9,1.9,2.7,3.0,1.3,1.1,1.4,1.3,2.1,3.0,3.6,1.5,1.2,0.4,1.73,1.03,1.80,2.27
39,OH,Ohio,2496,3371,2784,4635,2352,4664,4514,6108,11674,8818,6634,3993,13432,9228,10061,22054,11802,4478,5662,1805,0.6,0.8,0.6,1.0,0.5,1.0,0.9,1.3,2.5,1.9,1.4,0.9,2.9,2.0,2.2,5.0,2.8,1.0,1.3,0.4,1.72,0.77,1.84,2.46
53,WA,Washington,1945,2223,960,902,2029,1423,5563,3249,20421,2796,7401,1307,1030,1390,1843,5280,3541,2581,2297,1715,1.0,1.2,0.5,0.4,1.0,0.7,2.5,1.4,9.4,1.3,3.4,0.6,0.4,0.6,0.7,2.2,1.6,1.1,1.0,0.7,1.69,1.04,2.44,1.32
44,RI,Rhode Island,395,892,775,906,458,1032,586,361,530,679,350,931,1016,559,1257,808,629,456,52,65,1.1,2.4,2.1,2.4,1.2,2.6,1.4,0.9,1.3,1.6,0.8,2.2,2.4,1.3,3.0,2.0,1.6,1.1,0.1,0.2,1.64,1.87,1.50,1.57
13,GA,Georgia,3499,4634,7286,5536,6671,6796,2559,7597,6765,5266,4972,5382,5623,2755,4754,4342,3270,1956,1503,1251,1.3,1.7,2.5,1.8,2.1,2.1,0.8,2.2,2.1,1.6,1.5,1.6,1.6,0.8,1.4,1.3,1.0,0.6,0.5,0.4,1.51,1.76,1.65,0.96
16,ID,Idaho,301,548,680,952,458,229,210,963,1913,1703,171,515,90,893,455,1376,547,282,413,168,0.8,1.5,1.8,2.4,1.1,0.5,0.5,2.1,4.2,3.7,0.4,1.1,0.2,1.7,0.8,2.7,1.1,0.6,0.8,0.3,1.51,1.23,1.90,1.22
54,WV,West Virginia,602,901,820,428,428,1251,405,283,1559,899,927,475,1250,357,453,2508,1373,388,852,108,1.1,1.6,1.5,0.8,0.7,2.2,0.7,0.5,2.6,1.5,1.6,0.8,2.0,0.6,0.7,4.1,2.3,0.7,1.4,0.2,1.45,1.23,1.38,1.85
51,VA,Virginia,1623,1918,1336,2528,5156,2580,2923,6014,8306,6624,3837,2452,3742,2908,4274,6353,4634,2710,1254,825,0.7,0.8,0.5,1.0,1.9,0.9,1.0,2.1,2.9,2.3,1.3,0.8,1.2,0.9,1.4,2.1,1.6,0.9,0.4,0.3,1.38,0.98,1.66,1.28
40,OK,Oklahoma,2835,1432,871,458,741,1767,798,1176,5234,2746,1534,687,4116,1031,1814,1170,841,751,902,1472,2.8,1.4,0.8,0.4,0.6,1.5,0.7,1.0,4.4,2.3,1.3,0.6,3.4,0.8,1.4,0.9,0.7,0.6,0.7,1.2,1.30,1.18,1.96,0.88
20,KS,Kansas,715,432,690,402,213,1448,2398,150,5170,580,3800,265,666,133,440,325,1278,4582,641,989,0.8,0.5,0.7,0.4,0.2,1.3,2.2,0.1,4.7,0.5,3.6,0.2,0.6,0.1,0.4,0.3,1.2,4.3,0.6,0.9,1.27,0.86,1.42,1.35
35,NM,New Mexico,676,385,472,1579,729,2455,231,166,952,277,80,73,68,0,2645,1047,1141,34,474,0,1.4,0.8,0.9,3.0,1.4,4.5,0.4,0.3,1.7,0.5,0.1,0.1,0.1,0.0,4.1,1.7,1.9,0.1,0.8,0.0,1.26,1.76,0.40,1.69
29,MO,Missouri,2132,3288,1579,2393,722,3818,2424,3938,3069,3549,2296,2193,3631,1953,4140,3999,5457,2029,1121,1967,1.0,1.6,0.7,1.1,0.3,1.7,1.0,1.7,1.3,1.6,1.0,1.0,1.6,0.8,1.8,1.7,2.5,0.9,0.5,0.9,1.25,1.06,1.28,1.48
33,NH,New Hampshire,181,90,145,,731,828,390,1488,1076,650,566,1424,889,579,339,569,826,285,551,114,0.4,0.2,0.3,0.0,1.5,1.6,0.7,2.7,2.0,1.2,1.1,2.6,1.6,1.0,0.6,1.0,1.6,0.5,1.0,0.2,1.25,0.67,1.76,0.96
50,VT,Vermont,290,79,,100,,55,26,334,668,687,343,440,429,332,134,871,272,78,48,236,1.3,0.4,0.0,0.4,0.0,0.2,0.1,1.3,2.7,2.8,1.4,1.7,1.7,1.3,0.5,3.5,1.1,0.3,0.2,0.9,1.14,0.35,1.84,1.14
25,MA,Massachusetts,1878,3469,739,1862,2397,3835,2506,2109,3037,5940,2964,2429,2160,2927,2823,7072,2148,2059,3904,3420,0.8,1.4,0.3,0.7,0.9,1.4,0.9,0.7,1.1,2.1,1.1,0.9,0.8,1.0,1.0,2.5,0.8,0.7,1.4,1.2,1.07,0.89,1.09,1.28
17,IL,Illinois,2164,4212,1636,2289,3229,2784,2641,8015,10983,9588,7098,5712,3641,2942,3720,12707,8712,1699,2149,3282,0.5,0.9,0.3,0.5,0.6,0.5,0.5,1.5,2.2,1.9,1.4,1.1,0.7,0.6,0.7,2.6,1.8,0.4,0.4,0.7,1.06,0.55,1.36,1.19
48,TX,Texas,5319,6063,5728,9784,5735,21881,3664,6757,19624,9911,5128,4867,2098,5571,5581,9589,10197,4602,9669,4295,0.9,0.9,0.9,1.4,0.8,2.9,0.5,0.8,2.5,1.3,0.7,0.6,0.3,0.7,0.6,1.1,1.2,0.5,1.1,0.5,1.05,1.17,0.97,0.91
27,MN,Minnesota,1293,103,1107,854,899,925,491,3959,4616,4499,951,2006,812,2015,1963,5231,3331,1762,2527,1614,0.7,0.1,0.5,0.4,0.4,0.4,0.2,1.7,2.0,2.0,0.4,0.9,0.3,0.9,0.8,2.3,1.5,0.8,1.1,0.7,0.99,0.39,1.18,1.30
09,CT,Connecticut,425,423,209,1372,843,1211,416,1504,1378,1201,1861,810,956,1983,1568,1963,2578,1891,1466,510,0.3,0.3,0.2,1.0,0.6,0.8,0.3,1.0,1.0,0.9,1.3,0.6,0.7,1.4,1.1,1.4,1.9,1.4,1.0,0.4,0.97,0.50,0.97,1.36
30,MT,Montana,1223,434,310,446,516,262,248,218,362,622,0,282,,272,233,623,423,14,6,237,4.8,1.6,1.1,1.6,1.8,0.9,0.8,0.7,1.2,2.0,0.0,0.9,0.0,0.8,0.6,1.8,1.3,0.0,0.0,0.7,0.91,1.78,0.78,0.75
19,IA,Iowa,83,480,612,649,69,612,170,757,1026,1057,1189,705,3049,1143,1063,2817,1676,1723,191,1408,0.1,0.4,0.5,0.6,0.1,0.5,0.1,0.6,0.9,0.9,1.0,0.6,2.4,0.9,0.8,2.3,1.4,1.4,0.2,1.1,0.89,0.33,1.04,1.21
46,SD,South Dakota,0,0,,91,0,80,164,157,163,1381,55,364,15,,1161,925,,,86,11,0.0,0.0,0.0,0.3,0.0,0.3,0.5,0.5,0.5,4.5,0.2,1.2,0.0,0.0,3.5,2.8,0.0,0.0,0.3,0.0,0.86,0.16,1.00,1.30
22,LA,Louisiana,1459,490,841,4244,620,3107,230,2224,899,780,212,286,181,767,1684,1501,1177,569,2678,657,1.1,0.4,0.6,2.9,0.4,2.0,0.1,1.4,0.6,0.5,0.1,0.2,0.1,0.5,1.1,1.0,0.8,0.4,1.7,0.4,0.85,1.07,0.50,0.98
34,NJ,New Jersey,3583,5605,3910,2916,2992,4185,2425,2353,3090,5550,2219,2096,1217,2320,1875,4340,2798,1558,1381,868,1.2,1.9,1.3,0.9,0.9,1.3,0.7,0.7,0.9,1.7,0.7,0.6,0.4,0.7,0.5,1.3,0.9,0.5,0.4,0.3,0.85,1.18,0.80,0.73
04,AZ,Arizona,480,116,506,195,753,4788,147,530,1576,2141,1831,914,1382,1083,1799,5453,3477,464,475,446,0.4,0.1,0.3,0.1,0.4,2.7,0.1,0.3,0.8,1.1,0.9,0.4,0.6,0.5,0.8,2.6,1.8,0.2,0.2,0.2,0.83,0.59,0.68,1.13
56,WY,Wyoming,609,134,566,16,798,616,79,0,111,130,26,0,,,,46,,,,49,3.9,0.8,3.5,0.1,4.7,3.6,0.4,0.0,0.6,0.7,0.1,0.0,0.0,0.0,0.0,0.2,0.0,0.0,0.0,0.2,0.82,2.44,0.21,0.04
36,NY,New York,8688,7527,5474,4716,7056,6548,3678,4256,7015,8821,3849,5022,3566,4939,6381,5933,7674,8709,3756,3917,1.4,1.2,0.8,0.7,1.0,0.9,0.5,0.6,1.0,1.3,0.6,0.7,0.5,0.7,0.9,0.8,1.1,1.2,0.5,0.5,0.82,0.94,0.76,0.91
49,UT,Utah,365,922,731,700,973,309,123,1080,396,742,471,393,145,746,838,1309,1937,208,402,546,0.5,1.3,0.9,0.9,1.2,0.4,0.1,1.2,0.4,0.8,0.5,0.4,0.1,0.7,0.8,1.3,2.0,0.2,0.4,0.5,0.74,0.76,0.62,0.95
08,CO,Colorado,1302,1655,1299,129,685,3024,1945,555,809,1997,776,1419,2316,843,1498,1537,1950,730,1397,395,0.9,1.1,0.8,0.1,0.4,1.7,1.1,0.3,0.4,1.1,0.4,0.8,1.2,0.4,0.8,0.8,1.1,0.4,0.7,0.2,0.74,0.87,0.67,0.75
06,CA,California,3441,3292,6785,4252,3570,7848,7168,4511,13556,12250,7260,9584,10794,7488,9480,13149,14513,8170,6554,4628,0.3,0.3,0.6,0.4,0.3,0.7,0.6,0.4,1.1,1.0,0.6,0.8,0.8,0.6,0.7,1.1,1.2,0.7,0.5,0.4,0.72,0.47,0.75,0.86
31,NE,Nebraska,1,115,505,45,76,182,790,13,476,1535,918,162,153,730,218,1028,250,877,67,407,0.0,0.2,0.7,0.1,0.1,0.2,1.0,0.0,0.6,2.0,1.2,0.2,0.2,0.9,0.3,1.3,0.3,1.1,0.1,0.5,0.62,0.34,0.75,0.62
38,ND,North Dakota,527,92,197,21,637,463,0,,31,150,,27,76,0,173,452,453,0,,336,2.4,0.4,0.8,0.1,2.6,1.8,0.0,0.0,0.1,0.6,0.0,0.1,0.3,0.0,0.6,1.6,1.6,0.0,0.0,0.9,0.60,1.16,0.16,0.75
10,DE,Delaware,175,,0,0,,152,,0,2,348,324,245,149,39,1,1968,8,5,,22,0.6,0.0,0.0,0.0,0.0,0.4,0.0,0.0,0.0,1.0,0.9,0.7,0.4,0.1,0.0,5.4,0.0,0.0,0.0,0.1,0.53,0.14,0.43,1.09
24,MD,Maryland,670,2001,1141,820,844,793,517,212,637,2235,176,946,1379,1627,989,475,1206,1537,547,270,0.4,1.1,0.7,0.4,0.5,0.4,0.3,0.1,0.3,1.1,0.1,0.5,0.7,0.8,0.5,0.2,0.6,0.8,0.3,0.1,0.47,0.54,0.50,0.46
12,FL,Florida,1302,1006,1487,436,1546,2027,1137,2561,3480,1704,1109,1832,433,1033,1599,2941,2944,440,4421,2363,0.3,0.2,0.3,0.1,0.3,0.4,0.2,0.4,0.6,0.3,0.2,0.3,0.1,0.1,0.2,0.5,0.5,0.1,0.7,0.4,0.30,0.24,0.28,0.39
32,NV,Nevada,3,313,3,,41,1559,5,257,278,223,104,319,140,26,70,64,38,604,272,262,0.0,0.5,0.0,0.0,0.1,1.9,0.0,0.3,0.3,0.2,0.1,0.3,0.1,0.0,0.1,0.1,0.0,0.6,0.3,0.3,0.26,0.34,0.20,0.21
15,HI,Hawaii,295,0,,,,1,2,,,70,,149,,238,66,,7,,,232,0.7,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.2,0.0,0.3,0.0,0.5,0.1,0.0,0.0,0.0,0.0,0.5,0.06,0.10,0.14,0.03
11,DC,District of Columbia,,72,,,,,,,,5,1,0,,,,,50,,,,0.0,0.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.1,0.0,0.0,0.0,0.01,0.03,0.00,0.02
\ No newline at end of file
diff --git a/man/statebins.Rd b/man/statebins.Rd
index 9233872..d07e6bb 100644
--- a/man/statebins.Rd
+++ b/man/statebins.Rd
@@ -6,7 +6,7 @@
\usage{
statebins(state_data, state_col = "state", value_col = "value",
dark_label = "black", light_label = "white", font_size = 3,
- state_border_col = "white", state_border_size = 2,
+ state_border_col = "white", state_border_size = 2, round = FALSE,
ggplot2_scale_function = ggplot2::scale_fill_distiller, ...)
}
\arguments{
@@ -26,8 +26,12 @@ when the algorithm determines labels should be inverted.}
\item{state_border_size}{border size}
+\item{round}{rounded corners (default: \code{FALSE})}
+
\item{ggplot2_scale_function}{ggplot2 scale function to use. Defaults to \code{scale_fill_distiller}
since you're likely passing in continuous data when you shouldn't be :-)}
+
+\item{...}{additional parameters to the scale function}
}
\value{
ggplot2 object