Browse Source

Code coverage + appveyor + better theme

master
boB Rudis 6 years ago
parent
commit
7832c3ebe2
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 2
      .Rbuildignore
  2. 5
      .travis.yml
  3. 3
      DESCRIPTION
  4. 1
      R/statebins.R
  5. 13
      R/theme-statebin.R
  6. 25
      README.Rmd
  7. 46
      README.md
  8. BIN
      README_files/figure-gfm/all-1.png
  9. BIN
      README_files/figure-gfm/continuous-1.png
  10. BIN
      README_files/figure-gfm/continuous_noleg-1.png
  11. BIN
      README_files/figure-gfm/fert-1.png
  12. BIN
      README_files/figure-gfm/manual-1.png
  13. BIN
      README_files/figure-gfm/mort-1.png
  14. BIN
      README_files/figure-gfm/original-1.png
  15. BIN
      README_files/figure-gfm/rounded-1.png
  16. BIN
      README_files/figure-gfm/rounded2-1.png
  17. BIN
      README_files/figure-gfm/sb_facet-1.png
  18. 45
      appveyor.yml
  19. 12
      codecov.yml

2
.Rbuildignore

@ -13,3 +13,5 @@
^README.gfm-ascii_identifiers_files$
^README.gfm-ascii_identifiers_files/$
^README.gfm-ascii_identifiers_files/.*$
^appveyor\.yml$
^codecov\.yml$

5
.travis.yml

@ -1,5 +1,6 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
language: R
sudo: false
cache: packages
after_success:
- Rscript -e 'covr::codecov()'

3
DESCRIPTION

@ -30,7 +30,8 @@ License: MIT + file LICENSE
Suggests:
testthat,
viridis,
RColorBrewer
RColorBrewer,
covr
Depends:
R (>= 3.2.0),
Imports:

1
R/statebins.R

@ -83,6 +83,7 @@ statebins <- function(state_data,
gg <- gg + geom_text(data = st.dat,
aes_string(x = "col", y = "row", label = "abbrev"),
angle = 0,
color = .sb_invert(gb$data[[1]]$fill, dark_label, light_label),
size = font_size)

13
R/theme-statebin.R

@ -10,8 +10,9 @@ theme_statebins <- function(legend_position="bottom",
base_size = 11,
base_family = "") {
gg <- theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(axis.line = element_blank(),
gg <- theme_bw(base_size = base_size, base_family = base_family)
gg <- gg + theme(
axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
@ -21,11 +22,11 @@ theme_statebins <- function(legend_position="bottom",
panel.spacing = unit(0, "lines"),
plot.background = element_blank(),
legend.justification = c(0, 0),
legend.position = legend_position)
legend.position = legend_position
)
gg <- gg + theme(strip.background = element_rect(color="#2b2b2b", fill="white"))
gg <- gg + theme(plot.title=element_text(hjust=0.5))
gg <- gg + theme(axis.title.x=element_text(hjust=0.5))
gg <- gg + theme(plot.title=element_text(hjust=0.5, angle=0))
gg <- gg + theme(axis.title.x=element_text(hjust=0.5, angle=0))
gg <- gg + theme(legend.position=legend_position)
gg <- gg + theme(plot.title=element_text(size=16, hjust=0))
gg <- gg + theme(plot.margin = margin(30,30,30,30))

25
README.Rmd

@ -3,12 +3,19 @@ output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r ugh, echo=FALSE, message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
knitr::opts_chunk$set(message=FALSE, warning=FALSE, fig.retina=2)
options(width=120)
```
[![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/search/search.svg?branch=master)](https://travis-ci.org/search/search)
[![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)
```
# statebins
@ -49,7 +56,7 @@ packageVersion("statebins")
### The original wapo data
```{r original}
adat <- suppressMessages(read_csv(system.file("extdata", "wapostates.csv", package="statebins")))
adat <- read_csv(system.file("extdata", "wapostates.csv", package="statebins"))
mutate(
adat,
@ -68,9 +75,11 @@ mutate(
```{r continuous}
statebins(
adat, value_col = "avgshare01_07",
adat,
value_col = "avgshare01_07",
name = "Share of workforce with jobs lost or threatened by trade",
palette = "OrRd", direction = 1
palette = "OrRd",
direction = 1
) +
labs(x="2001-2007") +
theme_statebins(legend_position="top")
@ -89,7 +98,7 @@ statebins(adat, value_col = "avgshare08_12", palette = "Purples") +
```{r mort}
# from: http://www.cdc.gov/nchs/fastats/state-and-territorial-data.htm
dat <- suppressMessages(read_csv(system.file("extdata", "deaths.csv", package="statebins")))
dat <- read_csv(system.file("extdata", "deaths.csv", package="statebins"))
statebins(dat, value_col = "death_rate", name="Per 100K pop") +
labs(title="Mortality Rate (2010)") +

46
README.md

@ -1,4 +1,18 @@
[![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/statebins.svg?branch=master)](https://travis-ci.org/hrbrmstr/statebins)
[![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/search/search.svg?branch=master)](https://travis-ci.org/search/search)
[![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)
# statebins
@ -49,7 +63,7 @@ packageVersion("statebins")
### The original wapo data
``` r
adat <- suppressMessages(read_csv(system.file("extdata", "wapostates.csv", package="statebins")))
adat <- read_csv(system.file("extdata", "wapostates.csv", package="statebins"))
mutate(
adat,
@ -64,21 +78,23 @@ mutate(
theme_statebins()
```
<img src="README_files/figure-gfm/original-1.png" width="672" />
![](README_files/figure-gfm/original-1.png)<!-- -->
### Continuous scale, legend on top
``` r
statebins(
adat, value_col = "avgshare01_07",
adat,
value_col = "avgshare01_07",
name = "Share of workforce with jobs lost or threatened by trade",
palette = "OrRd", direction = 1
palette = "OrRd",
direction = 1
) +
labs(x="2001-2007") +
theme_statebins(legend_position="top")
```
<img src="README_files/figure-gfm/continuous-1.png" width="672" />
![](README_files/figure-gfm/continuous-1.png)<!-- -->
### Continuous scale, no legend
@ -88,21 +104,21 @@ statebins(adat, value_col = "avgshare08_12", palette = "Purples") +
theme_statebins(legend_position = "none")
```
<img src="README_files/figure-gfm/continuous_noleg-1.png" width="672" />
![](README_files/figure-gfm/continuous_noleg-1.png)<!-- -->
### Mortality data (has Puerto Rico)
``` r
# from: http://www.cdc.gov/nchs/fastats/state-and-territorial-data.htm
dat <- suppressMessages(read_csv(system.file("extdata", "deaths.csv", package="statebins")))
dat <- read_csv(system.file("extdata", "deaths.csv", package="statebins"))
statebins(dat, value_col = "death_rate", name="Per 100K pop") +
labs(title="Mortality Rate (2010)") +
theme_statebins()
```
<img src="README_files/figure-gfm/mort-1.png" width="672" />
![](README_files/figure-gfm/mort-1.png)<!-- -->
### Fertility data
@ -112,7 +128,7 @@ statebins(dat, value_col="fertility_rate", name="Per 100K pop", palette="PuBuGn"
theme_statebins()
```
<img src="README_files/figure-gfm/fert-1.png" width="672" />
![](README_files/figure-gfm/fert-1.png)<!-- -->
### Manual - perhaps good for elections?
@ -129,7 +145,7 @@ mutate(election_2012, value = ifelse(is.na(Obama), "Romney", "Obama")) %>%
theme_statebins()
```
<img src="README_files/figure-gfm/manual-1.png" width="672" />
![](README_files/figure-gfm/manual-1.png)<!-- -->
### Rounded rects\!
@ -145,7 +161,7 @@ statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE) +
theme_statebins(legend_position="right")
```
<img src="README_files/figure-gfm/rounded-1.png" width="672" />
![](README_files/figure-gfm/rounded-1.png)<!-- -->
Circles\!
@ -155,7 +171,7 @@ statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE,
theme_statebins(legend_position="right")
```
<img src="README_files/figure-gfm/rounded2-1.png" width="672" />
![](README_files/figure-gfm/rounded2-1.png)<!-- -->
### Geom
@ -175,7 +191,7 @@ ggplot(flu, aes(state=statename, fill=activity_level)) +
theme(plot.margin = margin(30,30,30,30))
```
<img src="README_files/figure-gfm/sb_facet-1.png" width="1632" />
![](README_files/figure-gfm/sb_facet-1.png)<!-- -->
### All the “states”
@ -208,4 +224,4 @@ statebins(us_arrests, value_col="Assault",
theme_statebins("right")
```
<img src="README_files/figure-gfm/all-1.png" width="672" />
![](README_files/figure-gfm/all-1.png)<!-- -->

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 38 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 37 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 30 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 36 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 35 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 37 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 35 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 42 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 63 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 KiB

After

Width:  |  Height:  |  Size: 247 KiB

45
appveyor.yml

@ -0,0 +1,45 @@
# DO NOT CHANGE the "init" and "install" sections below
# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'
install:
ps: Bootstrap
cache:
- C:\RLibrary
# Adapt as necessary starting from here
build_script:
- travis-tool.sh install_deps
test_script:
- travis-tool.sh run_tests
on_failure:
- 7z a failure.zip *.Rcheck\*
- appveyor PushArtifact failure.zip
artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs
- path: '*.Rcheck\**\*.out'
name: Logs
- path: '*.Rcheck\**\*.fail'
name: Logs
- path: '*.Rcheck\**\*.Rout'
name: Logs
- path: '\*_*.tar.gz'
name: Bits
- path: '\*_*.zip'
name: Bits

12
codecov.yml

@ -0,0 +1,12 @@
comment: false
coverage:
status:
project:
default:
target: auto
threshold: 1%
patch:
default:
target: auto
threshold: 1%
Loading…
Cancel
Save