diff --git a/.Rbuildignore b/.Rbuildignore
index 002dae8..693b8f5 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -3,3 +3,4 @@
^\.travis\.yml$
^README\.Rmd$
^README-.*\.png$
+^\.github$
diff --git a/.github/.gitignore b/.github/.gitignore
new file mode 100644
index 0000000..2d19fc7
--- /dev/null
+++ b/.github/.gitignore
@@ -0,0 +1 @@
+*.html
diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml
new file mode 100644
index 0000000..562fe0f
--- /dev/null
+++ b/.github/workflows/R-CMD-check.yaml
@@ -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")'
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 8d139ac..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
-
-language: R
-sudo: false
-cache: packages
diff --git a/DESCRIPTION b/DESCRIPTION
index 516fa28..2666871 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -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
diff --git a/NAMESPACE b/NAMESPACE
index 100a8b4..859fa83 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -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)
@@ -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)
@@ -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)
@@ -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)
@@ -122,4 +126,3 @@ export(trans_log2)
export(trans_none)
export(trans_sqrt)
import(grid)
-importFrom(magrittr,"%>%")
diff --git a/R/boxplot.r b/R/boxplot.r
index 9d85d1a..3204606 100644
--- a/R/boxplot.r
+++ b/R/boxplot.r
@@ -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)
@@ -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,
diff --git a/R/grobs-complex.r b/R/grobs-complex.r
index a5f6c93..9f950b3 100644
--- a/R/grobs-complex.r
+++ b/R/grobs-complex.r
@@ -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")
diff --git a/R/plot.r b/R/plot.r
index 7a3d56b..e777ee9 100644
--- a/R/plot.r
+++ b/R/plot.r
@@ -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
@@ -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)))
diff --git a/R/scales-list.r b/R/scales-list.r
index be49a11..2171ea6 100644
--- a/R/scales-list.r
+++ b/R/scales-list.r
@@ -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)
@@ -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)
diff --git a/R/time-series.r b/R/time-series.r
index 589c912..d399ccd 100644
--- a/R/time-series.r
+++ b/R/time-series.r
@@ -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])
diff --git a/R/utilities.r b/R/utilities.r
index 6b44346..7078865 100644
--- a/R/utilities.r
+++ b/R/utilities.r
@@ -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
diff --git a/README-ex-1.png b/README-ex-1.png
deleted file mode 100644
index dc35969..0000000
Binary files a/README-ex-1.png and /dev/null differ
diff --git a/README-ex-2.png b/README-ex-2.png
deleted file mode 100644
index 2448d44..0000000
Binary files a/README-ex-2.png and /dev/null differ
diff --git a/README.Rmd b/README.Rmd
index f372a0e..7092002 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -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)
+
+
+[![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)
+
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.
@@ -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()
```
diff --git a/README.md b/README.md
index 1ec1926..ac6faa8 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,23 @@
-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.
+
-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)
+
-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:
@@ -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)
+
``` 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)
+
diff --git a/man/figures/README-ex-1.png b/man/figures/README-ex-1.png
new file mode 100644
index 0000000..4851c02
Binary files /dev/null and b/man/figures/README-ex-1.png differ
diff --git a/man/figures/README-ex-2.png b/man/figures/README-ex-2.png
new file mode 100644
index 0000000..f0b1ce4
Binary files /dev/null and b/man/figures/README-ex-2.png differ
diff --git a/man/gghistogram.Rd b/man/gghistogram.Rd
index 0bd444d..9cf5193 100644
--- a/man/gghistogram.Rd
+++ b/man/gghistogram.Rd
@@ -4,8 +4,7 @@
\alias{gghistogram}
\title{Grob function: histogram}
\usage{
-gghistogram(plot, aesthetics = list(), scale = "prob", ...,
- data = NULL)
+gghistogram(plot, aesthetics = list(), scale = "prob", ..., data = NULL)
}
\arguments{
\item{plot}{the plot object to modify}
diff --git a/man/ggopt.Rd b/man/ggopt.Rd
index e6a30f4..595e497 100644
--- a/man/ggopt.Rd
+++ b/man/ggopt.Rd
@@ -7,7 +7,11 @@
\alias{ggopt}
\alias{ggtheme}
\title{Set global options for ggplot.}
-\format{An object of class \code{list} of length 2.}
+\format{
+An object of class \code{list} of length 2.
+
+An object of class \code{list} of length 11.
+}
\usage{
theme_bw
diff --git a/man/ggplot.Rd b/man/ggplot.Rd
index 33968e6..6c93df8 100644
--- a/man/ggplot.Rd
+++ b/man/ggplot.Rd
@@ -7,8 +7,7 @@
\usage{
ggplot(data, ...)
-\method{ggplot}{default}(data = NULL, aesthetics = list(),
- formula = . ~ ., margins = FALSE, ...)
+\method{ggplot}{default}(data = NULL, aesthetics = list(), formula = . ~ ., margins = FALSE, ...)
}
\arguments{
\item{data}{default data frame}
@@ -84,7 +83,7 @@ For scales that control position of the points see:
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
@@ -124,18 +123,18 @@ ggpoint(ggplot(tips, formula = . ~ sex, aesthetics = list(y = tip, x = total_bil
# 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)))
diff --git a/man/ggsave.Rd b/man/ggsave.Rd
index b884224..6711a4c 100644
--- a/man/ggsave.Rd
+++ b/man/ggsave.Rd
@@ -5,10 +5,17 @@
\title{ggsave
Save a ggplot with sensible defaults}
\usage{
-ggsave(plot, filename = default_name(plot),
- device = default_device(filename), scale = 1,
- width = graphics::par("din")[1], height = graphics::par("din")[2],
- grid = "normal", dpi = 96, ...)
+ggsave(
+ plot,
+ filename = default_name(plot),
+ device = default_device(filename),
+ scale = 1,
+ width = graphics::par("din")[1],
+ height = graphics::par("din")[2],
+ grid = "normal",
+ dpi = 96,
+ ...
+)
}
\arguments{
\item{plot}{plot to save}
diff --git a/man/pipe.Rd b/man/pipe.Rd
deleted file mode 100644
index ded5583..0000000
--- a/man/pipe.Rd
+++ /dev/null
@@ -1,12 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/utilities.r
-\name{\%>\%}
-\alias{\%>\%}
-\title{Pipe operator}
-\usage{
-lhs \%>\% rhs
-}
-\description{
-See \code{\link[magrittr]{\%>\%}} for more details.
-}
-\keyword{internal}
diff --git a/man/pscontinuous.Rd b/man/pscontinuous.Rd
index 36f0cf3..8bf1613 100644
--- a/man/pscontinuous.Rd
+++ b/man/pscontinuous.Rd
@@ -10,10 +10,27 @@
\alias{trans_inverse}
\title{Position: continuous
Add a continuous position scale to the plot}
-\format{An object of class \code{list} of length 2.}
+\format{
+An object of class \code{list} of length 2.
+
+An object of class \code{list} of length 2.
+
+An object of class \code{list} of length 2.
+
+An object of class \code{list} of length 2.
+
+An object of class \code{list} of length 2.
+}
\usage{
-pscontinuous(plot, variable = "x", name = "", transform = trans_none,
- range = c(NA, NA), expand = c(0.05, 0), breaks = NULL)
+pscontinuous(
+ plot,
+ variable = "x",
+ name = "",
+ transform = trans_none,
+ range = c(NA, NA),
+ expand = c(0.05, 0),
+ breaks = NULL
+)
trans_none
diff --git a/man/sccolour.Rd b/man/sccolour.Rd
index eb5a2ed..81205d9 100644
--- a/man/sccolour.Rd
+++ b/man/sccolour.Rd
@@ -7,14 +7,11 @@
\title{Scale: categorical colour
Create a scale for categorical colours.}
\usage{
-sccolour(plot, name = "", h = c(0, 360), l = 65, c = 100,
- alpha = 1)
+sccolour(plot, name = "", h = c(0, 360), l = 65, c = 100, alpha = 1)
-sccolor(plot, name = "", h = c(0, 360), l = 65, c = 100,
- alpha = 1)
+sccolor(plot, name = "", h = c(0, 360), l = 65, c = 100, alpha = 1)
-scfill(plot, name = "", h = c(0, 360), l = 75, c = 100,
- alpha = 1)
+scfill(plot, name = "", h = c(0, 360), l = 75, c = 100, alpha = 1)
}
\arguments{
\item{plot}{ggplot object}
diff --git a/man/scgradient.Rd b/man/scgradient.Rd
index ce37067..8e642a2 100644
--- a/man/scgradient.Rd
+++ b/man/scgradient.Rd
@@ -6,11 +6,25 @@
\title{Scale: colour gradient
Scale a continuous variable along a colour gradient.}
\usage{
-scgradient(plot, name = "", low = "red", mid = "white",
- high = "black", midpoint = 0, range = c(NA, NA))
-
-scfillgradient(plot, name = "", low = "red", mid = "white",
- high = "black", midpoint = 0, range = c(NA, NA))
+scgradient(
+ plot,
+ name = "",
+ low = "red",
+ mid = "white",
+ high = "black",
+ midpoint = 0,
+ range = c(NA, NA)
+)
+
+scfillgradient(
+ plot,
+ name = "",
+ low = "red",
+ mid = "white",
+ high = "black",
+ midpoint = 0,
+ range = c(NA, NA)
+)
}
\arguments{
\item{plot}{plot}
diff --git a/man/scmanual.Rd b/man/scmanual.Rd
index 74a500c..b51bb44 100644
--- a/man/scmanual.Rd
+++ b/man/scmanual.Rd
@@ -4,9 +4,14 @@
\alias{scmanual}
\title{Scale: manual}
\usage{
-scmanual(plot, variable = "x", name = "", breaks = NULL,
- labels = as.character(breaks), grob = function(x) grob_point(x,
- unique = FALSE))
+scmanual(
+ plot,
+ variable = "x",
+ name = "",
+ breaks = NULL,
+ labels = as.character(breaks),
+ grob = function(x) grob_point(x, unique = FALSE)
+)
}
\arguments{
\item{plot}{plot}