Skip to content

Commit

Permalink
Upkeep (#2)
Browse files Browse the repository at this point in the history
* travis -> GHA
* magrittr pipe -> base pipe
* Rename functions that look like S3 methods
* Other minor R CMD check failures
  • Loading branch information
hadley authored Nov 25, 2024
1 parent d0a686d commit 695d402
Show file tree
Hide file tree
Showing 27 changed files with 188 additions and 106 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^\.travis\.yml$
^README\.Rmd$
^README-.*\.png$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
51 changes: 51 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check.yaml

permissions: read-all

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

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

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

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

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ Description: This is the original ggplot package brought back to
License: GPL
URL: https://github.com/hadley/ggplot1
BugReports: https://github.com/hadley/ggplot1/issues
Depends:
R (>= 2.10)
Depends:
R (>= 4.2)
Imports:
ggplot2movies,
grid,
magrittr,
MASS,
plyr,
RColorBrewer,
reshape (>= 0.7.4)
Suggests:
ggplot2movies,
mapproj,
quantreg
Encoding: UTF-8
LazyData: yes
RoxygenNote: 6.1.1
RoxygenNote: 7.3.2
7 changes: 5 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ S3method("update<-",ps_equal)
S3method("update<-",ps_map)
S3method("update<-",scale)
S3method("update<-",scale_cont_colour)
S3method("update<-",scales)
S3method(breaks,categorical)
S3method(breaks,continuous)
S3method(breaks,gradient)
S3method(breaks,manual)
S3method(breaks,ps_double)
S3method(breaks,time)
S3method(defaultgrob,categorical)
S3method(defaultgrob,default)
S3method(defaultgrob,gradient)
Expand All @@ -34,6 +36,7 @@ S3method(labels,continuous)
S3method(labels,gradient)
S3method(labels,manual)
S3method(labels,ps_double)
S3method(labels,time)
S3method(map_aesthetic,categorical)
S3method(map_aesthetic,continuous)
S3method(map_aesthetic,gradient)
Expand All @@ -42,6 +45,7 @@ S3method(map_aesthetic,ps_double)
S3method(map_aesthetic,ps_map)
S3method(map_aesthetic,scale)
S3method(map_aesthetic,scale_cont_colour)
S3method(map_aesthetic,scales)
S3method(output,ps_double)
S3method(output,scale)
S3method(output,scale_cont_colour)
Expand All @@ -59,8 +63,8 @@ S3method(range,continuous)
S3method(range,ps_double)
S3method(range,scale)
S3method(range,scales)
S3method(range,time)
S3method(summary,ggplot1)
export("%>%")
export(alpha)
export(chop)
export(chop_auto)
Expand Down Expand Up @@ -122,4 +126,3 @@ export(trans_log2)
export(trans_none)
export(trans_sqrt)
import(grid)
importFrom(magrittr,"%>%")
6 changes: 3 additions & 3 deletions R/boxplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @keyword internal
# @alias boxplot.weighted
# @alias boxplot_stats_weighted
boxplot.weighted.formula <- function(formula, data = NULL, ..., weights=1, subset, na.action = NULL) {
boxplot_weighted_formula <- function(formula, data = NULL, ..., weights=1, subset, na.action = NULL) {
if (missing(formula) || (length(formula) != 3))
stop("'formula' missing or incorrect")
m <- match.call(expand.dots = FALSE)
Expand All @@ -16,10 +16,10 @@ boxplot.weighted.formula <- function(formula, data = NULL, ..., weights=1, subse
mf <- eval(m, parent.frame())
response <- attr(attr(mf, "terms"), "response")

boxplot.weighted(split(mf[[response]], mf[-response]), weights=split(weights, mf[-response]), ...)
boxplot_weighted(split(mf[[response]], mf[-response]), weights=split(weights, mf[-response]), ...)
}

boxplot.weighted <-
boxplot_weighted <-
function (x, weights=1, ..., range = 1.5, width = NULL, varwidth = FALSE,
notch = FALSE, outline = TRUE, names, plot = TRUE, border = graphics::par("fg"),
col = NULL, log = "", pars = list(boxwex = 0.8, staplewex = 0.5,
Expand Down
2 changes: 1 addition & 1 deletion R/grobs-complex.r
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ grob_boxplot <- function(aesthetics, breaks=length(unique(aesthetics$x)), orient
fill = tapply(rep(as.character(aesthetics$fill), length=n), breakpoints, function(x) x[1])
)

boxes <- boxplot.weighted.formula(aesthetics$y ~ breakpoints, weights=aesthetics$weight, plot=FALSE, ...)
boxes <- boxplot_weighted_formula(aesthetics$y ~ breakpoints, weights=aesthetics$weight, plot=FALSE, ...)
# lower whisker, lower hinge, median, upper hinge and upper whisker

outliers <- list(y = boxes$out, x = as.vector(xrange$median[boxes$group]), colour="red")
Expand Down
16 changes: 8 additions & 8 deletions R/plot.r
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#' For other scales, see:
#'
#' \itemize{
#' \item \code{\link{sccolour}}: colour categorical variables using Brewer colour scales (see also \'code{\link{scfill}})
#' \item \code{\link{sccolour}}: colour categorical variables using Brewer colour scales (see also \code{\link{scfill}})
#' \item \code{\link{scgradient}}: colour continuous scales with a gradient (see also \code{\link{scfillgradient}})
#' \item \code{\link{schcl}}: map continuous variable to hue, chroma or luminance components (see also \code{\link{scfillhcl}})
#' \item \code{\link{scmanual}}: no automatic conversion, uses raw values directly
Expand Down Expand Up @@ -107,18 +107,18 @@
#'
#' # Create complex plots from simple components
#' p <- ggplot(tips, formula = smoker ~ sex, aesthetics = list(y = tip, x = total_bill))
#' p %>% ggpoint()
#' p |> ggpoint()
#'
#' p %>%
#' ggpoint() %>%
#' p |>
#' ggpoint() |>
#' ggsmooth()
#'
#' p %>%
#' ggpoint() %>%
#' p |>
#' ggpoint() |>
#' ggsmooth(method = lm, formula = y~x)
#'
#' p %>%
#' ggpoint() %>%
#' p |>
#' ggpoint() |>
#' ggabline(slope = c(0.1,0.15,0.2))
#'
#' (p2 <- ggabline(ggpoint(p, aes = list(colour = tip/total_bill)), slope = c(0.1, 0.15, 0.2)))
Expand Down
2 changes: 2 additions & 0 deletions R/scales-list.r
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ guides.scales <- function(scale, ...) {
# @arguments scales object
# @arguments data
# @keyword internal
#' @export
"update<-.scales" <- function(x, value) {
if (is.matrix(value)) {
value <- do.call(plyr::rbind.fill, value)
Expand All @@ -81,6 +82,7 @@ guides.scales <- function(scale, ...) {
# @arguments data
# @arguments other arguments (unused)
# @keyword internal
#' @export
map_aesthetic.scales <- function(scale, data, ...) {
if (is.list(data) && !is.data.frame(data)) data <- data[[1]]
if (length(scale) == 0) return(data)
Expand Down
4 changes: 3 additions & 1 deletion R/time-series.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ position_time <- function(variable="x", name="", transform=trans_none, range=c(N
sc
}

#' @export
breaks.time <- function(scale, ...) {
sdates <- seq(scale$range[1], scale$range[2], by=scale$by)
scale$transform[[1]](as.numeric(sdates))
}


#' @export
labels.time <- function(object, ...) {
as.character(seq(object$range[1], object$range[2], by=object$by))
}

#' @export
range.time <- function(scale, ...)
expand_range(scale$range, scale$expand[1], scale$expand[2])

Expand Down
12 changes: 0 additions & 12 deletions R/utilities.r
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,3 @@ compact <- function(x) {
stamp <- function(...) {
suppressWarnings(reshape::stamp(...))
}

#' Pipe operator
#'
#' See \code{\link[magrittr]{\%>\%}} for more details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL
Binary file removed README-ex-1.png
Binary file not shown.
Binary file removed README-ex-2.png
Binary file not shown.
18 changes: 11 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ output: github_document
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# ggplot1
[![Travis-CI Build Status](https://travis-ci.org/hadley/ggplot1.svg?branch=master)](https://travis-ci.org/hadley/ggplot1)

<!-- badges: start -->
[![R-CMD-check](https://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svghttps://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svghttps://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

ggplot1 is an update of ggplot, the package that preceded ggplot2. ggplot1 is mostly made available out of historical interest, to illustrate how my thinking about API design in R has evolved over the years. I've made a few minor tweaks to the package, mostly fixing small things that obscure the interesting parts of the API.

Expand All @@ -33,12 +37,12 @@ devtools::install_github("hadley/ggplot1")
```{r ex}
library(ggplot1)
mtcars %>%
ggplot(list(x = mpg, y = wt)) %>%
mtcars |>
ggplot(list(x = mpg, y = wt)) |>
ggpoint()
mtcars %>%
ggplot(list(x = mpg, y = wt)) %>%
ggpoint(list(colour = gear)) %>%
mtcars |>
ggplot(list(x = mpg, y = wt)) |>
ggpoint(list(colour = gear)) |>
scbrewer()
```
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->
ggplot1
=======

[![Travis-CI Build Status](https://travis-ci.org/hadley/ggplot1.svg?branch=master)](https://travis-ci.org/hadley/ggplot1)
# ggplot1

ggplot1 is an update of ggplot, the package that preceded ggplot2. ggplot1 is mostly made available out of historical interest, to illustrate how my thinking about API design in R has evolved over the years. I've made a few minor tweaks to the package, mostly fixing small things that obscure the interesting parts of the API.
<!-- badges: start -->

ggplot had 7 CRAN releases starting with 0.2.2 in April 2006, and finishing with 0.4.2 in October 2008.
[![R-CMD-check](https://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svghttps://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svghttps://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hadley/ggplot1/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

Installation
------------
ggplot1 is an update of ggplot, the package that preceded ggplot2.
ggplot1 is mostly made available out of historical interest, to
illustrate how my thinking about API design in R has evolved over the
years. I’ve made a few minor tweaks to the package, mostly fixing small
things that obscure the interesting parts of the API.

ggplot had 7 CRAN releases starting with 0.2.2 in April 2006, and
finishing with 0.4.2 in October 2008.

## Installation

You can install ggplot1 from github with:

Expand All @@ -19,25 +26,24 @@ You can install ggplot1 from github with:
devtools::install_github("hadley/ggplot1")
```

Usage
-----
## Usage

``` r
library(ggplot1)

mtcars %>%
ggplot(list(x = mpg, y = wt)) %>%
mtcars |>
ggplot(list(x = mpg, y = wt)) |>
ggpoint()
```

![](README-ex-1.png)
<img src="man/figures/README-ex-1.png" width="100%" />

``` r

mtcars %>%
ggplot(list(x = mpg, y = wt)) %>%
ggpoint(list(colour = gear)) %>%
mtcars |>
ggplot(list(x = mpg, y = wt)) |>
ggpoint(list(colour = gear)) |>
scbrewer()
```

![](README-ex-2.png)
<img src="man/figures/README-ex-2.png" width="100%" />
Binary file added man/figures/README-ex-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-ex-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions man/gghistogram.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/ggopt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 695d402

Please sign in to comment.