Skip to content

Commit

Permalink
Cran V0.2.2 (#15)
Browse files Browse the repository at this point in the history
* Fixes #13
* Address some of #14
* Moves to GitHub Actions
  • Loading branch information
csgillespie authored Feb 10, 2021
1 parent bd4c0a7 commit 881a63a
Show file tree
Hide file tree
Showing 39 changed files with 671 additions and 132 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Rplots\.pdf
^cran-comments\.md$
^\.lintr$
^inst/\.lintr$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
75 changes: 75 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on: [push]
name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push:
branches:
- main
- master

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
5 changes: 3 additions & 2 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
linters: with_defaults(
assignment_linter = NULL, # 20
commented_code_linter = NULL,
NULL
)
object_name_linter = NULL,
line_length_linter(100),
cyclocomp_linter = NULL)
comment_bot: FALSE
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: prettyB
Title: Pretty Base Graphics
Version: 0.2.1.9001
Version: 0.2.2
Authors@R:
person(given = "Colin",
family = "Gillespie",
Expand All @@ -21,10 +21,11 @@ Suggests:
covr,
knitr,
lintr,
rmarkdown,
testthat,
vdiffr
VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# prettyB (development version)
# prettyB 0.2.2 _2021-02-09_
* Export add_y_axis & add_x_axis tick functions
* Improved `plot()` logic for the log scale
* Conditionally use {vdiffr} for testing (CRAN request)
* Bug: plot matrices fixes #13 (thanks to @gmonaie)
* BUg: barplot and axisnames. Fixes #14 (thanks to @yikeshu0611)

## Version 0.2.1
* Bug fix: Don't open plotting window when loading the package
Expand All @@ -9,7 +12,7 @@
* Implement `barplot_p()` method
* Implement `boxplot_p()` method
* Play nicely with existing S3 plotting methods, e.g. `plot.lm()`
* KISS: removed themes. If you want themes, use __ggplot2__
* KISS: removed themes. If you want themes, use {ggplot2}
* Made grid lines solid, instead of dashed
* Add vignette
* Update test suite
Expand Down
10 changes: 4 additions & 6 deletions R/barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ barplot.prettyB = function(height, width = 1, space = NULL, names.arg = NULL,
cex.names = par("cex.axis"), inside = TRUE,
plot = TRUE, axis.lty = 0, offset = 0,
add = FALSE, args.legend = NULL, ...) {
# op = set_par_minimal()
# on.exit(par(op))
setup_prettyB()

# Unchanged Arguments
Expand Down Expand Up @@ -57,7 +55,7 @@ barplot.prettyB = function(height, width = 1, space = NULL, names.arg = NULL,
if (!is.null(col)) {
args$col = col
} else if (is.matrix(height)) {
args$col = 1:NROW(height)
args$col = seq_len(NROW(height))
} else {
args$col = 1
}
Expand Down Expand Up @@ -114,7 +112,7 @@ barplot.prettyB = function(height, width = 1, space = NULL, names.arg = NULL,
lab = colnames(height)
} else {
lab_loc = res
if (is.matrix(height) ){
if (is.matrix(height)) {
lab = colnames(height)
} else {
lab_loc = res
Expand All @@ -124,10 +122,10 @@ barplot.prettyB = function(height, width = 1, space = NULL, names.arg = NULL,

if (isTRUE(args$horiz)) {
add_x_axis(ticks_x, tick = FALSE)
add_y_axis(lab_loc, labels = lab, tick = FALSE)
if (isTRUE(axisnames)) add_y_axis(lab_loc, labels = lab, tick = FALSE)
} else {
add_y_axis(ticks_y, tick = FALSE)
add_x_axis(lab_loc, labels = lab, tick = FALSE)
if (isTRUE(axisnames)) add_x_axis(lab_loc, labels = lab, tick = FALSE)
}
add_title(main)
add_sub(sub)
Expand Down
2 changes: 1 addition & 1 deletion R/par.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' @title Set up par and palette
#' Set up par and palette
#'
#' Sets up par and palette
#' @export
Expand Down
12 changes: 11 additions & 1 deletion R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,19 @@ plot.prettyB = function(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
# op = set_par_minimal()
# on.exit(par(op))

if (is.matrix(x)) {
if (ncol(x) > 1 && !is.null(y)) {
stop("x and y have different lengths (x is a matrix)", call. = FALSE)
}
if (ncol(x) > 1) {
y = x[, 2]
}
x = x[, 1]
}

## Do we have a y?
if (is.null(y)) {
x_tmp = 1:length(x)
x_tmp = seq_len(NROW(x)) # Handles the vector and matrix case
y_tmp = x
} else {
x_tmp = x
Expand Down
3 changes: 2 additions & 1 deletion R/prettyB-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#'
#' Anyone who uses R Base graphics, have a 100 and 1 tweaks that they use to make the
#' figures more presentable. This package aims to capture the tweaks in one place.
#' By masking_standard plotting functions, we can automatically make base graphics a bit more pretty.
#' By masking_standard plotting functions, we can automatically make base graphics a bit
#' more pretty.
#' @name prettyB-package
#' @aliases prettyB prettyb prettyB-package
#' @docType package
Expand Down
2 changes: 1 addition & 1 deletion R/qqnorm_minimal.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ## Need to remove main from new_args & pass it to do.call
# new_args$main = NULL
# res = do.call(stats_qqnorm_default, c(list(substitute(y), main=NULL), new_args))
# if(is_y(old_args$log)){
# if(is_y(old_args$log)) {
# ticks_y = axTicks(2)
# }
#
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ prettyB_pal = function(alpha = 255) {
}

#' @importFrom grDevices palette rgb
.onLoad = function(libname, pkgname){
.onLoad = function(libname, pkgname) {

# Cache current values
cache$palette = NULL
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ set.seed(1)

## Prettified Base Graphics

[![Build Status](https://travis-ci.org/jumpingrivers/prettyB.svg?branch=master)](https://travis-ci.org/jumpingrivers/prettyB)
[![R-CMD-check](https://github.com/jumpingrivers/prettyB/workflows/R-CMD-check/badge.svg)](https://github.com/jumpingrivers/prettyB/actions)
[![CRAN](http://www.r-pkg.org/badges/version/prettyB)](https://cran.r-project.org/package=prettyB)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Coverage status](https://codecov.io/gh/jumpingrivers/prettyB/branch/master/graph/badge.svg)](https://codecov.io/github/jumpingrivers/prettyB?branch=master)
[![Downloads](http://cranlogs.r-pkg.org/badges/prettyB?color=brightgreen)](https://cran.r-project.org/package=prettyB)

Expand Down Expand Up @@ -106,7 +106,7 @@ This package is __not__ a replacement for __ggplot2__ or other R related plottin
Since the generated plots by __prettyB__ use standard base graphics, with no new arguments, this makes plots future proof. As a fall-back, just remove the `_p`.
I picked up the general style a few years ago, but the book
[Fundamentals of Data Visualization](https://amzn.to/2Hct447) has made it a bit
[Fundamentals of Data Visualization](https://www.amazon.com/Fundamentals-Data-Visualization-Informative-Compelling/dp/1492031089/) has made it a bit
more consist. The author also provided a free
[online](https://serialmentor.com/dataviz/) version.
Expand Down
Loading

0 comments on commit 881a63a

Please sign in to comment.