From 8a321987353fdf5f685dd9c9067acc13b819e6aa Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Fri, 27 Jun 2025 18:33:35 +0800 Subject: [PATCH 1/2] adjust tests --- DESCRIPTION | 4 ++-- NEWS.md | 6 +++++- man/geom_km.Rd | 8 +++++--- man/geom_km_ticks.Rd | 8 +++++--- man/stat_km.Rd | 6 ++++-- man/stat_km_ticks.Rd | 6 ++++-- tests/testthat/test-geom_km.R | 25 +++++++++++++++++++------ tests/testthat/test-geom_km_ticks.R | 29 ++++++++++++++++++++++------- tests/testthat/test-stat_km.R | 20 +++++++++++++++----- tests/testthat/test-stat_km_ticks.R | 24 ++++++++++++++++++------ 10 files changed, 99 insertions(+), 37 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b0c0499..63116f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: ggplot2.utils Title: Selected Utilities Extending 'ggplot2' -Version: 0.3.2.9003 -Date: 2024-12-23 +Version: 0.3.3 +Date: 2025-06-27 Authors@R: c( person("Daniel", "Sabanés Bové", , "daniel.sabanes_bove@rconis.com", role = c("aut", "cre")), person("Samer", "Mouksassi", role = "aut", diff --git a/NEWS.md b/NEWS.md index 7f2edef..0fdcb6a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# ggplot2.utils 0.3.2.9003 +# ggplot2.utils 0.3.3 + +* Generalized one test to comply with the new `ggplot2` version. + +# ggplot2.utils 0.3.2 * Replaced dependency on `GGally` with `ggstats` where the original functions are actually from. This also avoids the corresponding overwrite messages coming from `GGally` when loading this package. diff --git a/man/geom_km.Rd b/man/geom_km.Rd index 082090a..a2309a2 100644 --- a/man/geom_km.Rd +++ b/man/geom_km.Rd @@ -38,7 +38,7 @@ from a \code{formula} (e.g. \code{~ head(.x, 10)}).} \item{stat}{The statistical transformation to use on the data for this layer. When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used the override the default coupling between geoms and +argument can be used to override the default coupling between geoms and stats. The \code{stat} argument accepts the following: \itemize{ \item A \code{Stat} ggproto subclass, for example \code{StatCount}. @@ -66,12 +66,14 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display.} +display. To include legend keys for all levels, even +when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, +but unobserved levels are omitted.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} diff --git a/man/geom_km_ticks.Rd b/man/geom_km_ticks.Rd index b6fde9f..2ef6b6a 100644 --- a/man/geom_km_ticks.Rd +++ b/man/geom_km_ticks.Rd @@ -38,7 +38,7 @@ from a \code{formula} (e.g. \code{~ head(.x, 10)}).} \item{stat}{The statistical transformation to use on the data for this layer. When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used the override the default coupling between geoms and +argument can be used to override the default coupling between geoms and stats. The \code{stat} argument accepts the following: \itemize{ \item A \code{Stat} ggproto subclass, for example \code{StatCount}. @@ -66,12 +66,14 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display.} +display. To include legend keys for all levels, even +when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, +but unobserved levels are omitted.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} diff --git a/man/stat_km.Rd b/man/stat_km.Rd index fb691b6..d5ab68a 100644 --- a/man/stat_km.Rd +++ b/man/stat_km.Rd @@ -65,12 +65,14 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display.} +display. To include legend keys for all levels, even +when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, +but unobserved levels are omitted.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} \item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These arguments broadly fall into one of 4 categories below. Notably, further diff --git a/man/stat_km_ticks.Rd b/man/stat_km_ticks.Rd index c54a977..f728bea 100644 --- a/man/stat_km_ticks.Rd +++ b/man/stat_km_ticks.Rd @@ -65,12 +65,14 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display.} +display. To include legend keys for all levels, even +when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, +but unobserved levels are omitted.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} \item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These arguments broadly fall into one of 4 categories below. Notably, further diff --git a/tests/testthat/test-geom_km.R b/tests/testthat/test-geom_km.R index 5649460..2dd7dc7 100644 --- a/tests/testthat/test-geom_km.R +++ b/tests/testthat/test-geom_km.R @@ -7,11 +7,21 @@ test_that("geom_km works as expected", { first_layer <- layer_data(result, 1) expect_data_frame(first_layer) - expect_named( - first_layer, - c( - "x", "y", "time", "survival", "PANEL", "group", "colour", "fill", - "linewidth", "linetype", "weight", "alpha" + expect_names( + names(first_layer), + must.include = c( + "x", + "y", + "time", + "survival", + "PANEL", + "group", + "colour", + "fill", + "linewidth", + "linetype", + "weight", + "alpha" ) ) }) @@ -23,7 +33,10 @@ test_that("geom_km looks as expected for a single group", { }) test_that("geom_km looks as expected for two groups", { - p <- ggplot(surv_df, aes(time = time, status = status, color = factor(group))) + + p <- ggplot( + surv_df, + aes(time = time, status = status, color = factor(group)) + ) + geom_km() vdiffr::expect_doppelganger("geom_km two groups", p) }) diff --git a/tests/testthat/test-geom_km_ticks.R b/tests/testthat/test-geom_km_ticks.R index 22979a8..c93cac4 100644 --- a/tests/testthat/test-geom_km_ticks.R +++ b/tests/testthat/test-geom_km_ticks.R @@ -7,12 +7,24 @@ test_that("geom_km_ticks works as expected", { first_layer <- layer_data(result, 1) expect_data_frame(first_layer) - expect_named( - first_layer, - c( - "x", "y", "time", "survival", "n.risk", "n.censor", "n.event", - "PANEL", "group", "shape", "colour", "size", "alpha", - "stroke", "fill" + expect_names( + names(first_layer), + must.include = c( + "x", + "y", + "time", + "survival", + "n.risk", + "n.censor", + "n.event", + "PANEL", + "group", + "shape", + "colour", + "size", + "alpha", + "stroke", + "fill" ) ) }) @@ -24,7 +36,10 @@ test_that("geom_km_ticks looks as expected for a single group", { }) test_that("geom_km_ticks looks as expected for two groups", { - p <- ggplot(surv_df, aes(time = time, status = status, color = factor(group))) + + p <- ggplot( + surv_df, + aes(time = time, status = status, color = factor(group)) + ) + geom_km_ticks() vdiffr::expect_doppelganger("geom_km_ticks two groups", p) }) diff --git a/tests/testthat/test-stat_km.R b/tests/testthat/test-stat_km.R index e6c7dc6..88f4e77 100644 --- a/tests/testthat/test-stat_km.R +++ b/tests/testthat/test-stat_km.R @@ -7,11 +7,21 @@ test_that("stat_km works as expected", { first_layer <- layer_data(result, 1) expect_data_frame(first_layer) - expect_named( - first_layer, - c( - "x", "y", "time", "survival", "PANEL", "group", "colour", "fill", - "linewidth", "linetype", "weight", "alpha" + expect_names( + names(first_layer), + must.include = c( + "x", + "y", + "time", + "survival", + "PANEL", + "group", + "colour", + "fill", + "linewidth", + "linetype", + "weight", + "alpha" ) ) }) diff --git a/tests/testthat/test-stat_km_ticks.R b/tests/testthat/test-stat_km_ticks.R index b38cd1c..dc55a6a 100644 --- a/tests/testthat/test-stat_km_ticks.R +++ b/tests/testthat/test-stat_km_ticks.R @@ -7,12 +7,24 @@ test_that("stat_km_ticks works as expected", { first_layer <- layer_data(result, 1) expect_data_frame(first_layer) - expect_named( - first_layer, - c( - "x", "y", "time", "survival", "n.risk", "n.censor", "n.event", - "PANEL", "group", "shape", "colour", "size", "alpha", - "stroke", "fill" + expect_names( + names(first_layer), + must.include = c( + "x", + "y", + "time", + "survival", + "n.risk", + "n.censor", + "n.event", + "PANEL", + "group", + "shape", + "colour", + "size", + "alpha", + "stroke", + "fill" ) ) }) From 9ede752bf7abb269ac2a91e9eb2b943a9b2fbf5d Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Mon, 7 Jul 2025 09:06:49 +0800 Subject: [PATCH 2/2] update docs --- man/geom_km.Rd | 8 +++----- man/geom_km_ticks.Rd | 8 +++----- man/stat_km.Rd | 6 ++---- man/stat_km_ticks.Rd | 6 ++---- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/man/geom_km.Rd b/man/geom_km.Rd index a2309a2..082090a 100644 --- a/man/geom_km.Rd +++ b/man/geom_km.Rd @@ -38,7 +38,7 @@ from a \code{formula} (e.g. \code{~ head(.x, 10)}).} \item{stat}{The statistical transformation to use on the data for this layer. When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used to override the default coupling between geoms and +argument can be used the override the default coupling between geoms and stats. The \code{stat} argument accepts the following: \itemize{ \item A \code{Stat} ggproto subclass, for example \code{StatCount}. @@ -66,14 +66,12 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display. To include legend keys for all levels, even -when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, -but unobserved levels are omitted.} +display.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} diff --git a/man/geom_km_ticks.Rd b/man/geom_km_ticks.Rd index 2ef6b6a..b6fde9f 100644 --- a/man/geom_km_ticks.Rd +++ b/man/geom_km_ticks.Rd @@ -38,7 +38,7 @@ from a \code{formula} (e.g. \code{~ head(.x, 10)}).} \item{stat}{The statistical transformation to use on the data for this layer. When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used to override the default coupling between geoms and +argument can be used the override the default coupling between geoms and stats. The \code{stat} argument accepts the following: \itemize{ \item A \code{Stat} ggproto subclass, for example \code{StatCount}. @@ -66,14 +66,12 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display. To include legend keys for all levels, even -when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, -but unobserved levels are omitted.} +display.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} diff --git a/man/stat_km.Rd b/man/stat_km.Rd index d5ab68a..fb691b6 100644 --- a/man/stat_km.Rd +++ b/man/stat_km.Rd @@ -65,14 +65,12 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display. To include legend keys for all levels, even -when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, -but unobserved levels are omitted.} +display.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} \item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These arguments broadly fall into one of 4 categories below. Notably, further diff --git a/man/stat_km_ticks.Rd b/man/stat_km_ticks.Rd index f728bea..c54a977 100644 --- a/man/stat_km_ticks.Rd +++ b/man/stat_km_ticks.Rd @@ -65,14 +65,12 @@ to use \code{position_jitter()}, give the position as \code{"jitter"}. \code{NA}, the default, includes if any aesthetics are mapped. \code{FALSE} never includes, and \code{TRUE} always includes. It can also be a named logical vector to finely select the aesthetics to -display. To include legend keys for all levels, even -when no data exists, use \code{TRUE}. If \code{NA}, all levels are shown in legend, -but unobserved levels are omitted.} +display.} \item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[ggplot2:annotation_borders]{annotation_borders()}}.} +the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.} \item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}'s \code{params} argument. These arguments broadly fall into one of 4 categories below. Notably, further