Browse Source

state dataset added; documentation cleanup; README regen'd

master
boB Rudis 2 years ago
parent
commit
5dbebe92f8
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 23
      DESCRIPTION
  3. 3
      NEWS.md
  4. 6
      R/aaa.R
  5. 12
      R/statebins-package.R
  6. 6
      README.Rmd
  7. 33
      README.md
  8. 24
      data-raw/DATASET.R
  9. BIN
      data/state_tbl.rda
  10. BIN
      man/figures/README-all-1.png
  11. BIN
      man/figures/README-continuous-1.png
  12. BIN
      man/figures/README-continuous_noleg-1.png
  13. BIN
      man/figures/README-fert-1.png
  14. BIN
      man/figures/README-mort-1.png
  15. BIN
      man/figures/README-rounded-1.png
  16. BIN
      man/figures/README-rounded2-1.png
  17. BIN
      man/figures/README-sb_facet-1.png
  18. 22
      man/geom_statebins.Rd
  19. 9
      man/state_tbl.Rd
  20. 12
      man/statebins-package.Rd
  21. 20
      man/statebins.Rd
  22. 3
      man/theme_statebins.Rd

1
.Rbuildignore

@ -15,3 +15,4 @@
^README.gfm-ascii_identifiers_files/.*$
^appveyor\.yml$
^codecov\.yml$
^data-raw$

23
DESCRIPTION

@ -1,8 +1,8 @@
Package: statebins
Type: Package
Title: Create 'U.S.' Uniform Square State Cartogram Heatmaps
Version: 2.0.0
Date: 2017-11-14
Title: Create United States Uniform Cartogram Heatmaps
Version: 1.4.0
Date: 2020-07-08
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
@ -16,16 +16,17 @@ Authors@R: c(
comment = "Minor fix for NA handling")
)
Maintainer: Bob Rudis <bob@rud.is>
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
Description: The cartogram heatmaps generated by the included methods
are an alternative to choropleth maps for the United 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/>.
(<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
possible but have 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.
URL: https://github.com/hrbrmstr/statebins
BugReports: https://github.com/hrbrmstr/statebins/issues
URL: https://gitlab.com/hrbrmstr/statebins
BugReports: https://gitlab.com/hrbrmstr/statebins/issues
License: MIT + file LICENSE
Encoding: UTF-8
Suggests:
@ -34,12 +35,12 @@ Suggests:
RColorBrewer,
covr
Depends:
R (>= 3.2.0),
R (>= 3.5.0),
Imports:
ggplot2 (>= 2.2.1),
scales (>= 0.5.0),
grid
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
Collate:
'aaa.R'
'geom-oscar.R'

3
NEWS.md

@ -1,3 +1,6 @@
# statebins 1.4.0
* New `state_tbl` dataset to make it easier to complete partial state data data frames
# statebins 1.3.0
* Added support for `VI`/`Virgin Islands`
* Supports auto-computation of when to use light & dark label colors

6
R/aaa.R

@ -32,3 +32,9 @@ state_coords <- state_coords[order(state_coords$state),]
b_state_coords <- state_coords
colnames(b_state_coords) <- c("abbrev", "state", "x", "y")
b_state_coords$y <- -b_state_coords$y
#' "State" abbreviation to name data frame
#'
#' @name state_tbl
#' @docType data
NULL

12
R/statebins-package.R

@ -1,4 +1,14 @@
#' statebins is an alternative to choropleth maps for U.S. States
#' Create United States Uniform Cartogram Heatmaps
#'
#' The cartogram heatmaps generated by the included methods
#' are an alternative to choropleth maps for the United 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 have 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.
#'
#' @md
#' @name statebins-package

6
README.Rmd

@ -18,11 +18,13 @@ hrbrpkghelpr::yank_title_and_description()
## What's Inside The Tin
The following functions are implemented:
The following functions are implemented/datasets included:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
- `statebins`: (the original sole function in the package) Create a new ggplot-based "statebin" chart for USA states/territories
## Installation
@ -143,7 +145,7 @@ statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE,
### Geom
```{r sb_facet, fig.width=17, fig.height=10}
```{r sb_facet, fig.width=20, fig.height=15}
flu <- ili_weekly_activity_indicators(2017)
ggplot(flu, aes(state=statename, fill=activity_level)) +

33
README.md

@ -5,7 +5,7 @@ developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.re
[![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)
%](https://img.shields.io/badge/Signed_Commits-96%25-lightgrey.svg)
[![Linux build
Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![Windows build
@ -17,36 +17,45 @@ checks](https://cranchecks.info/badges/worst/statebins)](https://cranchecks.info
[![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)
Version](https://img.shields.io/badge/R%3E%3D-3.5.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
# statebins
Create ‘U.S.’ Uniform Square State Cartogram Heatmaps
Create United States Uniform Cartogram Heatmaps
## 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/>.
The cartogram heatmaps generated by the included methods are an
alternative to choropleth maps for the United 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.
as possible but have 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:
The following functions are implemented/datasets included:
- `geom_statebins`: A statebins Geom
- `state_tbl`: “State” abbreviation to name data frame
- `theme_statebins`: Base statebins theme
- `statebins`: (the original sole function in the package) Create a
new ggplot-based “statebin” chart for USA states/territories
## Installation
``` r
install.packages("statebins", repos = "https://cinc.rud.is")
install.packages("statebins) # NOTE: CRAN version is 1.2.2
# or
install.packages("statebins", repos = c("https://cinc.rud.is", "https://cloud.r-project.org/"))
# or
remotes::install_git("https://git.rud.is/hrbrmstr/statebins.git")
# or
@ -78,7 +87,7 @@ library(tidyverse)
# current verison
packageVersion("statebins")
## [1] '2.0.0'
## [1] '1.4.0'
```
### The original wapo data
@ -212,7 +221,7 @@ ggplot(flu, aes(state=statename, fill=activity_level)) +
theme(plot.margin = margin(30,30,30,30))
```
<img src="man/figures/README-sb_facet-1.png" width="1632" />
<img src="man/figures/README-sb_facet-1.png" width="1920" />
### All the “states”

24
data-raw/DATASET.R

@ -0,0 +1,24 @@
## code to prepare `DATASET` dataset goes here
state_tbl <- structure(list(abbrev = c("AL", "AK", "AZ", "AR", "CA", "CO",
"CT", "DC", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS",
"KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE",
"NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA",
"RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY",
"PR", "VI", "NYC"),
state = c("Alabama", "Alaska", "Arizona", "Arkansas",
"California", "Colorado", "Connecticut", "District of Columbia",
"Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois",
"Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine",
"Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi",
"Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire",
"New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota",
"Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
"South Carolina", "South Dakota", "Tennessee", "Texas", "Utah",
"Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming",
"Puerto Rico", "Virgin Islands", "New York City")),
.Names = c("abbrev", "state"),
class = "data.frame", row.names = c(NA, -54L))
usethis::use_data(state_tbl, overwrite = TRUE)

BIN
data/state_tbl.rda

Binary file not shown.

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 25 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 28 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 634 KiB

22
man/geom_statebins.Rd

@ -5,12 +5,24 @@
\alias{geom_statebins}
\alias{GeomStatebins}
\title{A statebins Geom}
\format{An object of class \code{GeomStatebins} (inherits from \code{Geom}, \code{ggproto}, \code{gg}) of length 7.}
\format{
An object of class \code{GeomStatebins} (inherits from \code{Geom}, \code{ggproto}, \code{gg}) of length 7.
}
\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)
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
)
GeomStatebins
}

9
man/state_tbl.Rd

@ -0,0 +1,9 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/aaa.R
\docType{data}
\name{state_tbl}
\alias{state_tbl}
\title{"State" abbreviation to name data frame}
\description{
"State" abbreviation to name data frame
}

12
man/statebins-package.Rd

@ -3,9 +3,17 @@
\docType{package}
\name{statebins-package}
\alias{statebins-package}
\title{statebins is an alternative to choropleth maps for U.S. States}
\title{Create United States Uniform Cartogram Heatmaps}
\description{
statebins is an alternative to choropleth maps for U.S. States
The cartogram heatmaps generated by the included methods
are an alternative to choropleth maps for the United States
and are based on work by the Washington Post graphics department in their report
on "The states most threatened by trade"
(\url{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 have 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.
}
\author{
Bob Rudis (bob@rud.is)

20
man/statebins.Rd

@ -4,11 +4,21 @@
\alias{statebins}
\title{Create a new ggplot-based "statebin" chart for USA states/territories}
\usage{
statebins(state_data, state_col = "state", value_col = "value",
dark_label = "black", light_label = "white", na_label = "white",
font_size = 3, state_border_col = "white", state_border_size = 2,
round = FALSE, radius = grid::unit(6, "pt"),
ggplot2_scale_function = ggplot2::scale_fill_distiller, ...)
statebins(
state_data,
state_col = "state",
value_col = "value",
dark_label = "black",
light_label = "white",
na_label = "white",
font_size = 3,
state_border_col = "white",
state_border_size = 2,
round = FALSE,
radius = grid::unit(6, "pt"),
ggplot2_scale_function = ggplot2::scale_fill_distiller,
...
)
}
\arguments{
\item{state_data}{data frame of states and values to plot}

3
man/theme_statebins.Rd

@ -4,8 +4,7 @@
\alias{theme_statebins}
\title{Base statebins theme}
\usage{
theme_statebins(legend_position = "bottom", base_size = 11,
base_family = "")
theme_statebins(legend_position = "bottom", base_size = 11, base_family = "")
}
\arguments{
\item{legend_position}{fills in \code{legend.position}}

Loading…
Cancel
Save