Compare commits

...

No commits in common. '717a6d1b15bd890531edf3fec2a27b7e3d2dceea' and '006702f0e58bc6b95af43d77483c507177571619' have entirely different histories.

  1. 3
      .github/FUNDING.yml
  2. 2
      DESCRIPTION
  3. 1
      R/geom-statebins.r
  4. 37
      README.Rmd
  5. 89
      README.md
  6. BIN
      README_files/figure-gfm/all-1.png
  7. BIN
      README_files/figure-gfm/continuous-1.png
  8. BIN
      README_files/figure-gfm/continuous_noleg-1.png
  9. BIN
      README_files/figure-gfm/fert-1.png
  10. BIN
      README_files/figure-gfm/manual-1.png
  11. BIN
      README_files/figure-gfm/mort-1.png
  12. BIN
      README_files/figure-gfm/original-1.png
  13. BIN
      README_files/figure-gfm/rounded-1.png
  14. BIN
      README_files/figure-gfm/rounded2-1.png
  15. BIN
      README_files/figure-gfm/sb_facet-1.png
  16. BIN
      man/figures/README-all-1.png
  17. BIN
      man/figures/README-continuous-1.png
  18. BIN
      man/figures/README-continuous_noleg-1.png
  19. BIN
      man/figures/README-fert-1.png
  20. BIN
      man/figures/README-manual-1.png
  21. BIN
      man/figures/README-mort-1.png
  22. BIN
      man/figures/README-original-1.png
  23. BIN
      man/figures/README-rounded-1.png
  24. BIN
      man/figures/README-rounded2-1.png
  25. BIN
      man/figures/README-sb_facet-1.png
  26. 4
      man/geom_statebins.Rd

3
.github/FUNDING.yml

@ -0,0 +1,3 @@
# These are supported funding model platforms
patreon: hrbrmstr

2
DESCRIPTION

@ -39,7 +39,7 @@ Imports:
ggplot2 (>= 2.2.1),
scales (>= 0.5.0),
grid
RoxygenNote: 6.0.1.9000
RoxygenNote: 6.1.1
Collate:
'aaa.R'
'geom-oscar.R'

1
R/geom-statebins.r

@ -150,7 +150,6 @@ GeomStatebins <- ggplot2::ggproto("GeomStatebins", ggplot2::Geom,
radius = grid::unit(6, "pt")) {
tile_data <- data
tile_data$size <- 2
tile_data$colour <- border_col
tile_data$size <- border_size

37
README.Rmd

@ -4,41 +4,32 @@ editor_options:
chunk_output_type: console
---
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![Build Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![minimal R version](https://img.shields.io/badge/R%3E%3D-3.2.0-6666ff.svg)](https://cran.r-project.org/)
[![packageversion](https://img.shields.io/badge/Package%20version-2.0.0-orange.svg?style=flat-square)](commits/master)
![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/statebins)
[![](http://cranlogs.r-pkg.org/badges/statebins)](http://cran.rstudio.com/web/packages/statebins/index.html)
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/statebins?branch=master&svg=true)](https://ci.appveyor.com/project/hrbrmstr/statebins)
```{r include=FALSE}
knitr::opts_chunk$set(message=FALSE, warning=FALSE)
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
# statebins
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
Create 'U.S.' Uniform Square State Cartogram Heatmaps
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```
## What's in the tin?
## What's Inside The Tin
The following functions are implemented:
- `statebins`: Creates "statebin" charts in the style of http://bit.ly/statebins
- `geom_statebins`: A statebins Geom (WIP!)
- `theme_statebins`: Base statebins theme
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Installation
```{r install, eval=FALSE}
devtools::install_github("hrbrmstr/statebins")
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## NOTE
Due to a number of things, this is dependent on the _development_ version of ggplot2 and now identifies that in the `DESCRIPTION` metadata, _including_ a `Remotes:` field (which will be removed when this & ggplot2 hit CRAN).
## Usage
All of the following examples use the [WaPo data](http://www.washingtonpost.com/wp-srv/special/business/states-most-threatened-by-trade/states.csv?cache=1). It looks like the columns they use are scaled data and I didn't take the time to figure out what they did, so the final figure just mimics their output (including the non-annotated legend).

89
README.md

@ -1,44 +1,66 @@
[![Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![Build
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![minimal R
version](https://img.shields.io/badge/R%3E%3D-3.2.0-6666ff.svg)](https://cran.r-project.org/)
[![packageversion](https://img.shields.io/badge/Package%20version-2.0.0-orange.svg?style=flat-square)](commits/master)
![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/statebins)
[![](http://cranlogs.r-pkg.org/badges/statebins)](http://cran.rstudio.com/web/packages/statebins/index.html)
[![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![AppVeyor Build
Status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/statebins?branch=master&svg=true)](https://ci.appveyor.com/project/hrbrmstr/statebins)
[![Windows build
status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/statebins?svg=true)](https://ci.appveyor.com/project/hrbrmstr/statebins)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/statebins/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/statebins)
[![cran
checks](https://cranchecks.info/badges/worst/statebins)](https://cranchecks.info/pkgs/statebins)
[![CRAN
status](https://www.r-pkg.org/badges/version/statebins)](https://www.r-pkg.org/pkg/statebins)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# statebins
Create ‘U.S.’ Uniform Square State Cartogram Heatmaps
## What’s in the tin?
## Description
Cartogram heatmaps are an alternative to choropleth maps for ‘USA’
States and are based on work by the ‘Washington Post’ graphics
department in their report on “The states most threatened by trade”
<http://www.washingtonpost.com/wp-srv/special/business/states-most-threatened-by-trade/>.
“State bins” preserve as much of the geographic placement of the states
as possible but has the look and feel of a traditional heatmap.
Functions are provided that allow for use of a binned, discrete scale, a
continuous scale or manually specified colors depending on what is
needed for the underlying data.
## What’s Inside The Tin
The following functions are implemented:
- `statebins`: Creates “statebin” charts in the style of
<http://bit.ly/statebins>
- `geom_statebins`: A statebins Geom (WIP\!)
- `geom_statebins`: A statebins Geom
- `theme_statebins`: Base statebins theme
## Installation
``` r
devtools::install_github("hrbrmstr/statebins")
install.packages("statebins", repos = "https://cinc.rud.is")
# or
remotes::install_git("https://git.rud.is/hrbrmstr/statebins.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/statebins")
# or
remotes::install_gitlab("hrbrmstr/statebins")
# or
remotes::install_bitbucket("hrbrmstr/statebins")
# or
remotes::install_github("hrbrmstr/statebins")
```
## NOTE
Due to a number of things, this is dependent on the *development*
version of ggplot2 and now identifies that in the `DESCRIPTION`
metadata, *including* a `Remotes:` field (which will be removed when
this & ggplot2 hit CRAN).
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
## Usage
@ -56,10 +78,9 @@ library(tidyverse)
# current verison
packageVersion("statebins")
## [1] '2.0.0'
```
## [1] '2.0.0'
### The original wapo data
``` r
@ -78,7 +99,7 @@ mutate(
theme_statebins()
```
![](README_files/figure-gfm/original-1.png)<!-- -->
<img src="man/figures/README-original-1.png" width="672" />
### Continuous scale, legend on top
@ -94,7 +115,7 @@ statebins(
theme_statebins(legend_position="top")
```
![](README_files/figure-gfm/continuous-1.png)<!-- -->
<img src="man/figures/README-continuous-1.png" width="672" />
### Continuous scale, no legend
@ -104,7 +125,7 @@ statebins(adat, value_col = "avgshare08_12", palette = "Purples") +
theme_statebins(legend_position = "none")
```
![](README_files/figure-gfm/continuous_noleg-1.png)<!-- -->
<img src="man/figures/README-continuous_noleg-1.png" width="672" />
### Mortality data (has Puerto Rico)
@ -118,7 +139,7 @@ statebins(dat, value_col = "death_rate", name="Per 100K pop") +
theme_statebins()
```
![](README_files/figure-gfm/mort-1.png)<!-- -->
<img src="man/figures/README-mort-1.png" width="672" />
### Fertility data
@ -128,7 +149,7 @@ statebins(dat, value_col="fertility_rate", name="Per 100K pop", palette="PuBuGn"
theme_statebins()
```
![](README_files/figure-gfm/fert-1.png)<!-- -->
<img src="man/figures/README-fert-1.png" width="672" />
### Manual - perhaps good for elections?
@ -145,7 +166,7 @@ mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
theme_statebins()
```
![](README_files/figure-gfm/manual-1.png)<!-- -->
<img src="man/figures/README-manual-1.png" width="672" />
### Rounded rects\!
@ -161,7 +182,7 @@ statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE) +
theme_statebins(legend_position="right")
```
![](README_files/figure-gfm/rounded-1.png)<!-- -->
<img src="man/figures/README-rounded-1.png" width="672" />
Circles\!
@ -171,7 +192,7 @@ statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE,
theme_statebins(legend_position="right")
```
![](README_files/figure-gfm/rounded2-1.png)<!-- -->
<img src="man/figures/README-rounded2-1.png" width="672" />
### Geom
@ -191,7 +212,7 @@ ggplot(flu, aes(state=statename, fill=activity_level)) +
theme(plot.margin = margin(30,30,30,30))
```
![](README_files/figure-gfm/sb_facet-1.png)<!-- -->
<img src="man/figures/README-sb_facet-1.png" width="1632" />
### All the “states”
@ -224,4 +245,4 @@ statebins(us_arrests, value_col="Assault",
theme_statebins("right")
```
![](README_files/figure-gfm/all-1.png)<!-- -->
<img src="man/figures/README-all-1.png" width="672" />

BIN
README_files/figure-gfm/all-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
README_files/figure-gfm/continuous-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

BIN
README_files/figure-gfm/continuous_noleg-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

BIN
README_files/figure-gfm/fert-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
README_files/figure-gfm/manual-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

BIN
README_files/figure-gfm/mort-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

BIN
README_files/figure-gfm/original-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

BIN
README_files/figure-gfm/rounded-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

BIN
README_files/figure-gfm/rounded2-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

BIN
README_files/figure-gfm/sb_facet-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

BIN
man/figures/README-all-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
man/figures/README-continuous-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
man/figures/README-continuous_noleg-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
man/figures/README-fert-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
man/figures/README-manual-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
man/figures/README-mort-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
man/figures/README-original-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
man/figures/README-rounded-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
man/figures/README-rounded2-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
man/figures/README-sb_facet-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

4
man/geom_statebins.Rd

@ -9,8 +9,8 @@
\usage{
geom_statebins(mapping = NULL, data = NULL, border_col = "white",
border_size = 2, lbl_size = 3, dark_lbl = "black",
light_lbl = "white", radius = grid::unit(6, "pt"), ..., na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE)
light_lbl = "white", radius = grid::unit(6, "pt"), ...,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
GeomStatebins
}

Loading…
Cancel
Save