From 1dc2f575bc0e948e3a2a671be0a9924b77d38bf0 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 5 Nov 2025 17:25:46 +0100 Subject: [PATCH 1/5] utility to manage lifecycles --- R/utilities.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/R/utilities.R b/R/utilities.R index 4f3d96c084..9775df192d 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -784,6 +784,26 @@ as_cli <- function(..., env = caller_env()) { cli::cli_fmt(cli::cli_text(..., .envir = env)) } +deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL, + escalate = FALSE) { + + defunct <- "3.0.0" + full <- "3.4.0" + soft <- packageVersion("ggplot2") + + version <- as.package_version(when) + if (version < defunct) { + lifecycle::deprecate_stop(when, ...) + } + user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) + if (version <= full) { + lifecycle::deprecate_warn(when, ..., id = id, always = always, user_env = user_env) + } else if (version <= soft) { + lifecycle::deprecate_soft(when, ..., id = id, user_env = user_env) + } + invisible() +} + deprecate_soft0 <- function(..., user_env = NULL) { user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) lifecycle::deprecate_soft(..., user_env = user_env) From 55c6acce4352112b1c3ba8f7fdfdb3167cf7e888 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 5 Nov 2025 17:30:08 +0100 Subject: [PATCH 2/5] replace soft deprecations --- R/annotation-borders.R | 2 +- R/annotation-logticks.R | 2 +- R/axis-secondary.R | 2 +- R/coord-.R | 2 +- R/coord-transform.R | 2 +- R/facet-.R | 2 +- R/facet-wrap.R | 2 +- R/geom-boxplot.R | 2 +- R/geom-crossbar.R | 2 +- R/geom-errorbar.R | 4 ++-- R/geom-label.R | 2 +- R/geom-pointrange.R | 2 +- R/geom-violin.R | 2 +- R/ggproto.R | 2 +- R/guide-colorbar.R | 2 +- R/guide-legend.R | 2 +- R/guide-old.R | 2 +- R/plot-construction.R | 2 +- R/plot.R | 2 +- R/scale-.R | 10 +++++----- R/stat-ydensity.R | 2 +- R/theme-elements.R | 12 ++++++------ R/theme.R | 8 ++++---- R/utilities.R | 7 +------ 24 files changed, 37 insertions(+), 42 deletions(-) diff --git a/R/annotation-borders.R b/R/annotation-borders.R index 5f725d80a1..6e4f1faa00 100644 --- a/R/annotation-borders.R +++ b/R/annotation-borders.R @@ -46,6 +46,6 @@ annotation_borders <- function(database = "world", regions = ".", fill = NA, #' @rdname annotation_borders #' @usage borders(...) # Deprecated borders <- function(...) { - deprecate_soft0("4.0.0", "borders()", "annotation_borders()") + deprecate("4.0.0", "borders()", "annotation_borders()") annotation_borders(...) } diff --git a/R/annotation-logticks.R b/R/annotation-logticks.R index 7fa69aa843..548a89470b 100644 --- a/R/annotation-logticks.R +++ b/R/annotation-logticks.R @@ -96,7 +96,7 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled lifecycle::signal_stage("superseded", "annotation_logticks()", "guide_axis_logticks()") if (lifecycle::is_present(size)) { - deprecate_soft0("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`")) + deprecate("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`")) linewidth <- linewidth %||% size } diff --git a/R/axis-secondary.R b/R/axis-secondary.R index d694cf3a47..9e114fe6f6 100644 --- a/R/axis-secondary.R +++ b/R/axis-secondary.R @@ -100,7 +100,7 @@ sec_axis <- function(transform = NULL, name = waiver(), breaks = waiver(), labels = waiver(), guide = waiver(), trans = deprecated()) { if (lifecycle::is_present(trans)) { - deprecate_soft0("3.5.0", "sec_axis(trans)", "sec_axis(transform)") + deprecate("3.5.0", "sec_axis(trans)", "sec_axis(transform)") transform <- trans } diff --git a/R/coord-.R b/R/coord-.R index b14d95584c..32a8e4a42a 100644 --- a/R/coord-.R +++ b/R/coord-.R @@ -696,7 +696,7 @@ is_coord <- function(x) inherits(x, "Coord") #' @rdname is_tests #' @usage is.Coord(x) # Deprecated is.Coord <- function(x) { - deprecate_soft0("3.5.2", "is.Coord()", "is_coord()") + deprecate("3.5.2", "is.Coord()", "is_coord()") is_coord(x) } diff --git a/R/coord-transform.R b/R/coord-transform.R index 89922b09c6..0154de5062 100644 --- a/R/coord-transform.R +++ b/R/coord-transform.R @@ -112,7 +112,7 @@ coord_transform <- function(x = "identity", y = "identity", xlim = NULL, ylim = #' @rdname coord_transform #' @export coord_trans <- function(...) { - deprecate_soft0( + deprecate( "4.0.0", "coord_trans()", "coord_transform()" diff --git a/R/facet-.R b/R/facet-.R index 7aa06695d0..3b5ecfe671 100644 --- a/R/facet-.R +++ b/R/facet-.R @@ -939,7 +939,7 @@ is_facet <- function(x) inherits(x, "Facet") #' @rdname is_tests #' @usage is.facet(x) # Deprecated is.facet <- function(x) { - deprecate_soft0("3.5.2", "is.facet()", "is_facet()") + deprecate("3.5.2", "is.facet()", "is_facet()") is_facet(x) } diff --git a/R/facet-wrap.R b/R/facet-wrap.R index 51fccb37b7..acb414d416 100644 --- a/R/facet-wrap.R +++ b/R/facet-wrap.R @@ -568,7 +568,7 @@ wrap_layout <- function(id, dims, dir) { if (nchar(dir) != 2) { # Should only occur when `as.table` was not incorporated into `dir` dir <- switch(dir, h = "lt", v = "tl") - deprecate_soft0( + deprecate( "4.0.0", what = I("Internal use of `dir = \"h\"` and `dir = \"v\"` in `facet_wrap()`"), details = I(c( diff --git a/R/geom-boxplot.R b/R/geom-boxplot.R index 78bdbacc30..8a0eac2abe 100644 --- a/R/geom-boxplot.R +++ b/R/geom-boxplot.R @@ -240,7 +240,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom, setup_params = function(data, params) { if ("fatten" %in% names(params)) { - deprecate_soft0( + deprecate( "4.0.0", "geom_boxplot(fatten)", "geom_boxplot(median.linewidth)" ) diff --git a/R/geom-crossbar.R b/R/geom-crossbar.R index 2547219ac6..672f5df98e 100644 --- a/R/geom-crossbar.R +++ b/R/geom-crossbar.R @@ -61,7 +61,7 @@ geom_crossbar <- function(mapping = NULL, data = NULL, GeomCrossbar <- ggproto("GeomCrossbar", Geom, setup_params = function(data, params) { if (lifecycle::is_present(params$fatten %||% deprecated())) { - deprecate_soft0( + deprecate( "4.0.0", "geom_crossbar(fatten)", "geom_crossbar(middle.linewidth)" ) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index 1c17828e71..34ec88094c 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -77,7 +77,7 @@ GeomErrorbar <- ggproto( GeomErrorbarh <- ggproto( "GeomErrorbarh", GeomErrorbar, setup_params = function(data, params) { - deprecate_soft0( + deprecate( "4.0.0", "geom_errorbarh()", "geom_errorbar(orientation = \"y\")", id = "no-more-errorbarh" ) @@ -95,7 +95,7 @@ geom_errorbar <- make_constructor(GeomErrorbar, orientation = NA) #' `geom_errorbarh()` is `r lifecycle::badge("deprecated")`. Use #' `geom_errorbar(orientation = "y")` instead. geom_errorbarh <- function(..., orientation = "y") { - deprecate_soft0( + deprecate( "4.0.0", "geom_errorbarh()", "geom_errorbar(orientation = \"y\")", id = "no-more-errorbarh" ) diff --git a/R/geom-label.R b/R/geom-label.R index dfa4dae5e1..296469f866 100644 --- a/R/geom-label.R +++ b/R/geom-label.R @@ -28,7 +28,7 @@ geom_label <- function(mapping = NULL, data = NULL, extra_args <- list2(...) if (lifecycle::is_present(label.size)) { - deprecate_soft0("3.5.0", "geom_label(label.size)", "geom_label(linewidth)") + deprecate("3.5.0", "geom_label(label.size)", "geom_label(linewidth)") extra_args$linewidth <- extra_args$linewidth %||% label.size } diff --git a/R/geom-pointrange.R b/R/geom-pointrange.R index 4f3603f485..b05dbfda10 100644 --- a/R/geom-pointrange.R +++ b/R/geom-pointrange.R @@ -16,7 +16,7 @@ GeomPointrange <- ggproto("GeomPointrange", Geom, setup_params = function(data, params) { if (lifecycle::is_present(params$fatten %||% deprecated())) { - deprecate_soft0("4.0.0", "geom_pointrange(fatten)", I("the `size` aesthetic")) + deprecate("4.0.0", "geom_pointrange(fatten)", I("the `size` aesthetic")) } else { # For backward compatibility reasons params$fatten <- 4 diff --git a/R/geom-violin.R b/R/geom-violin.R index 5ba06844f3..30ae9d526d 100644 --- a/R/geom-violin.R +++ b/R/geom-violin.R @@ -111,7 +111,7 @@ geom_violin <- function(mapping = NULL, data = NULL, extra <- list() if (lifecycle::is_present(draw_quantiles)) { - deprecate_soft0( + deprecate( "4.0.0", what = "geom_violin(draw_quantiles)", with = "geom_violin(quantiles.linetype)" diff --git a/R/ggproto.R b/R/ggproto.R index 853a440f9f..4e7ccc6e30 100644 --- a/R/ggproto.R +++ b/R/ggproto.R @@ -113,7 +113,7 @@ is_ggproto <- function(x) inherits(x, "ggproto") #' @rdname is_tests #' @usage is.ggproto(x) # Deprecated is.ggproto <- function(x) { - deprecate_soft0("3.5.2", "is.ggproto()", "is_ggproto()") + deprecate("3.5.2", "is.ggproto()", "is_ggproto()") is_ggproto(x) } diff --git a/R/guide-colorbar.R b/R/guide-colorbar.R index 862e3b8d55..ca37574f21 100644 --- a/R/guide-colorbar.R +++ b/R/guide-colorbar.R @@ -139,7 +139,7 @@ guide_colourbar <- function( ... ) { if (lifecycle::is_present(raster)) { - deprecate_soft0("3.5.0", "guide_colourbar(raster)", "guide_colourbar(display)") + deprecate("3.5.0", "guide_colourbar(raster)", "guide_colourbar(display)") check_bool(raster) display <- if (raster) "raster" else "rectangles" } diff --git a/R/guide-legend.R b/R/guide-legend.R index 6378300c6d..7430b4a2fa 100644 --- a/R/guide-legend.R +++ b/R/guide-legend.R @@ -734,7 +734,7 @@ deprecated_guide_args <- function( fun_name <- call_name(.call) replacement <- paste0(fun_name, "(theme)") for (arg_name in names(vals)) { - deprecate_soft0( + deprecate( when = "3.5.0", what = paste0(fun_name, "(", arg_name, ")"), with = replacement diff --git a/R/guide-old.R b/R/guide-old.R index 8f8be86ba1..62da30fec3 100644 --- a/R/guide-old.R +++ b/R/guide-old.R @@ -65,7 +65,7 @@ guide_gengrob.default <- guide_train.default #' @export #' @rdname old_guide old_guide <- function(guide) { - deprecate_soft0( + deprecate( when = "3.5.0", what = I("The S3 guide system"), details = c( diff --git a/R/plot-construction.R b/R/plot-construction.R index b65890cc32..e0a88fc8e5 100644 --- a/R/plot-construction.R +++ b/R/plot-construction.R @@ -81,7 +81,7 @@ S7::method(`+`, list(class_theme, S7::class_any)) <- function(e1, e2) { #' @export "%+%" <- function(e1, e2) { if (getRversion() >= "4.3.0") { - deprecate_soft0("4.0.0", I(" %+% x"), I(" + x")) + deprecate("4.0.0", I(" %+% x"), I(" + x")) } add_gg(e1, e2) } diff --git a/R/plot.R b/R/plot.R index f831b086d1..401fbbc221 100644 --- a/R/plot.R +++ b/R/plot.R @@ -162,7 +162,7 @@ is_ggplot <- function(x) S7::S7_inherits(x, class_ggplot) #' @rdname is_tests #' @usage is.ggplot(x) # Deprecated is.ggplot <- function(x) { - deprecate_soft0("3.5.2", "is.ggplot()", "is_ggplot()") + deprecate("3.5.2", "is.ggplot()", "is_ggplot()") is_ggplot(x) } diff --git a/R/scale-.R b/R/scale-.R index d9837c8e15..c90ebd1d16 100644 --- a/R/scale-.R +++ b/R/scale-.R @@ -114,10 +114,10 @@ continuous_scale <- function(aesthetics, scale_name = deprecated(), palette, nam super = ScaleContinuous) { call <- call %||% current_call() if (lifecycle::is_present(scale_name)) { - deprecate_soft0("3.5.0", "continuous_scale(scale_name)") + deprecate("3.5.0", "continuous_scale(scale_name)") } if (lifecycle::is_present(trans)) { - deprecate_soft0("3.5.0", "continuous_scale(trans)", "continuous_scale(transform)") + deprecate("3.5.0", "continuous_scale(trans)", "continuous_scale(transform)") transform <- trans } @@ -224,7 +224,7 @@ discrete_scale <- function(aesthetics, scale_name = deprecated(), palette, name super = ScaleDiscrete) { call <- call %||% current_call() if (lifecycle::is_present(scale_name)) { - deprecate_soft0("3.5.0", "discrete_scale(scale_name)") + deprecate("3.5.0", "discrete_scale(scale_name)") } aesthetics <- standardise_aes_names(aesthetics) @@ -321,10 +321,10 @@ binned_scale <- function(aesthetics, scale_name = deprecated(), palette, name = call = caller_call(), super = ScaleBinned) { if (lifecycle::is_present(scale_name)) { - deprecate_soft0("3.5.0", "binned_scale(scale_name)") + deprecate("3.5.0", "binned_scale(scale_name)") } if (lifecycle::is_present(trans)) { - deprecate_soft0("3.5.0", "binned_scale(trans)", "binned_scale(transform)") + deprecate("3.5.0", "binned_scale(trans)", "binned_scale(transform)") transform <- trans } diff --git a/R/stat-ydensity.R b/R/stat-ydensity.R index 0828df91f1..6ead824981 100644 --- a/R/stat-ydensity.R +++ b/R/stat-ydensity.R @@ -11,7 +11,7 @@ StatYdensity <- ggproto( params$flipped_aes <- has_flipped_aes(data, params, main_is_orthogonal = TRUE, group_has_equal = TRUE) if (!is.null(params$draw_quantiles)) { - deprecate_soft0( + deprecate( "4.0.0", what = "stat_ydensity(draw_quantiles)", with = "stat_ydensity(quantiles)" diff --git a/R/theme-elements.R b/R/theme-elements.R index 3f69eacfb3..73c545794e 100644 --- a/R/theme-elements.R +++ b/R/theme-elements.R @@ -397,15 +397,15 @@ rel <- function(x) { # Element getter methods local({ S7::method(`$`, element) <- function(x, i) { - # deprecate_soft0("4.1.0", I("`$i`"), I("`@i`")) + deprecate("4.1.0", I("`$i`"), I("`@i`")) `[[`(S7::props(x), i) } S7::method(`[`, element) <- function(x, i) { - # deprecate_soft0("4.1.0", I("`[i]`"), I("`S7::props(, i)`")) + deprecate("4.1.0", I("`[i]`"), I("`S7::props(, i)`")) `[`(S7::props(x), i) } S7::method(`[[`, element) <- function(x, i) { - # deprecate_soft0("4.1.0", I("`[[i]]`"), I("`S7::prop(, i)`")) + deprecate("4.1.0", I("`[[i]]`"), I("`S7::prop(, i)`")) `[[`(S7::props(x), i) } }) @@ -413,21 +413,21 @@ local({ # Element setter methods #' @export `$<-.ggplot2::element` <- function(x, i, value) { - # deprecate_soft0("4.1.0", I("`$i <- value`"), I("`@i <- value`")) + deprecate("4.1.0", I("`$i <- value`"), I("`@i <- value`")) S7::props(x) <- `[[<-`(S7::props(x), i, value) x } #' @export `[<-.ggplot2::element` <- function(x, i, value) { - # deprecate_soft0("4.1.0", I("`[i] <- value`"), I("`S7::props()[i] <- value`")) + deprecate("4.1.0", I("`[i] <- value`"), I("`S7::props()[i] <- value`")) S7::props(x) <- `[<-`(S7::props(x), i, value) x } #' @export `[[<-.ggplot2::element` <- function(x, i, value) { - # deprecate_soft0("4.1.0", I("`[[i]] <- value`"), I("S7::prop(, i) <- value")) + deprecate("4.1.0", I("`[[i]] <- value`"), I("S7::prop(, i) <- value")) S7::props(x) <- `[[<-`(S7::props(x), i, value) x } diff --git a/R/theme.R b/R/theme.R index bab9e23b5a..eb7ca09fe7 100644 --- a/R/theme.R +++ b/R/theme.R @@ -515,7 +515,7 @@ fix_theme_deprecations <- function(elements) { elements$legend.margin <- margin() } if (!is.null(elements$legend.title.align)) { - deprecate_soft0( + deprecate( "3.5.0", "theme(legend.title.align)", I("theme(legend.title = element_text(hjust))") ) @@ -528,7 +528,7 @@ fix_theme_deprecations <- function(elements) { elements$legend.title.align <- NULL } if (!is.null(elements$legend.text.align)) { - deprecate_soft0( + deprecate( "3.5.0", "theme(legend.text.align)", I("theme(legend.text = element_text(hjust))") ) @@ -541,7 +541,7 @@ fix_theme_deprecations <- function(elements) { elements$legend.text.align <- NULL } if (is.numeric(elements[["legend.position"]])) { - deprecate_soft0( + deprecate( "3.5.0", I("A numeric `legend.position` argument in `theme()`"), "theme(legend.position.inside)" ) @@ -599,7 +599,7 @@ is_theme <- function(x) S7::S7_inherits(x, class_theme) #' @rdname is_tests #' @usage is.theme(x) # Deprecated is.theme <- function(x) { - deprecate_soft0("3.5.2", "is.theme()", "is_theme()") + deprecate("3.5.2", "is.theme()", "is_theme()") is_theme(x) } diff --git a/R/utilities.R b/R/utilities.R index 9775df192d..71522e8fed 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -716,7 +716,7 @@ with_ordered_restart <- function(expr, .call) { ")" ) - deprecate_soft0( + deprecate( "3.4.0", I(msg), details = desc @@ -804,11 +804,6 @@ deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL, invisible() } -deprecate_soft0 <- function(..., user_env = NULL) { - user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) - lifecycle::deprecate_soft(..., user_env = user_env) -} - deprecate_warn0 <- function(..., user_env = NULL) { user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) lifecycle::deprecate_warn(..., user_env = user_env) From a75da7387178b98890d5cd8bcb7de79bd1ac0afe Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 6 Nov 2025 09:45:45 +0100 Subject: [PATCH 3/5] add option to bump severity --- R/utilities.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/utilities.R b/R/utilities.R index 71522e8fed..5fda819f3d 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -785,18 +785,18 @@ as_cli <- function(..., env = caller_env()) { } deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL, - escalate = FALSE) { + escalate = NULL) { defunct <- "3.0.0" full <- "3.4.0" soft <- packageVersion("ggplot2") version <- as.package_version(when) - if (version < defunct) { + if (version < defunct || identical(escalate, "abort")) { lifecycle::deprecate_stop(when, ...) } user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) - if (version <= full) { + if (version <= full || identical(escalate, "warn")) { lifecycle::deprecate_warn(when, ..., id = id, always = always, user_env = user_env) } else if (version <= soft) { lifecycle::deprecate_soft(when, ..., id = id, user_env = user_env) From 02a6cdeba53165cc5b94e715df11883110760ffd Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 6 Nov 2025 09:58:18 +0100 Subject: [PATCH 4/5] replace `deprecate_warn` --- R/aes-evaluation.R | 4 ++-- R/aes.R | 4 ++-- R/bin.R | 6 ------ R/coord-radial.R | 15 +++++++++------ R/coord-transform.R | 4 ++-- R/fortify-map.R | 4 ++-- R/fortify-models.R | 25 +++++++++++++++---------- R/fortify-spatial.R | 21 ++++++++++++++------- R/geom-.R | 4 ++-- R/geom-sf.R | 5 ++++- R/guide-axis-logticks.R | 15 +++++++++------ R/guides-.R | 4 ++-- R/layer.R | 6 +++--- R/quick-plot.R | 2 +- R/scale-expansion.R | 2 +- R/stat-summary-bin.R | 6 +++--- R/stat-summary.R | 6 +++--- R/theme-elements.R | 8 ++++---- R/utilities.R | 7 +------ 19 files changed, 79 insertions(+), 69 deletions(-) diff --git a/R/aes-evaluation.R b/R/aes-evaluation.R index f906d4bc2d..3136a16ad4 100644 --- a/R/aes-evaluation.R +++ b/R/aes-evaluation.R @@ -257,7 +257,7 @@ is_calculated <- function(x, warn = FALSE) { what <- I(paste0("The dot-dot notation (`", x, "`)")) var <- gsub(match_calculated_aes, "\\1", as.character(x)) with <- I(paste0("`after_stat(", var, ")`")) - deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot") + deprecate("3.4.0", what, with, id = "ggplot-warn-aes-dot-dot") } res } else if (is_quosure(x)) { @@ -268,7 +268,7 @@ is_calculated <- function(x, warn = FALSE) { what <- I(paste0("`", expr_deparse(x), "`")) x[[1]] <- quote(after_stat) with <- I(paste0("`", expr_deparse(x), "`")) - deprecate_warn0("3.4.0", what, with, id = "ggplot-warn-aes-stat") + deprecate("3.4.0", what, with, id = "ggplot-warn-aes-stat") } TRUE } else { diff --git a/R/aes.R b/R/aes.R index 208053bf52..e8a19ad037 100644 --- a/R/aes.R +++ b/R/aes.R @@ -283,7 +283,7 @@ is_position_aes <- function(vars) { #' #' @export aes_ <- function(x, y, ...) { - deprecate_warn0( + deprecate( "3.0.0", "aes_()", details = "Please use tidy evaluation idioms with `aes()`" @@ -310,7 +310,7 @@ aes_ <- function(x, y, ...) { #' @rdname aes_ #' @export aes_string <- function(x, y, ...) { - deprecate_warn0( + deprecate( "3.0.0", "aes_string()", details = c( diff --git a/R/bin.R b/R/bin.R index 81a49aebec..6c7044b06b 100644 --- a/R/bin.R +++ b/R/bin.R @@ -247,12 +247,6 @@ bin_loc <- function(x, id) { fix_bin_params <- function(params, fun, version) { - if (package_version(version) < "3.0.0") { - deprecate <- lifecycle::deprecate_stop - } else { - deprecate <- deprecate_warn0 - } - if (!is.null(params$origin)) { args <- paste0(fun, c("(origin)", "(boundary)")) deprecate(version, args[1], args[2]) diff --git a/R/coord-radial.R b/R/coord-radial.R index 32dd33599e..5da19ff481 100644 --- a/R/coord-radial.R +++ b/R/coord-radial.R @@ -123,20 +123,23 @@ coord_radial <- function(theta = "x", rotate_angle = deprecated()) { if (lifecycle::is_present(r_axis_inside)) { - deprecate_warn0( - "3.5.1", "coord_radial(r_axis_inside)", "coord_radial(r.axis.inside)" + deprecate( + "coord_radial(r_axis_inside)", "coord_radial(r.axis.inside)", + when = "3.5.1", escalate = "warn" ) r.axis.inside <- r_axis_inside } if (lifecycle::is_present(rotate_angle)) { - deprecate_warn0( - "3.5.1", "coord_radial(rotate_angle)", "coord_radial(rotate.angle)" + deprecate( + "coord_radial(rotate_angle)", "coord_radial(rotate.angle)", + when = "3.5.1", escalate = "warn" ) rotate.angle <- rotate_angle } if (lifecycle::is_present(direction)) { - deprecate_warn0( - "4.0.0", "coord_radial(direction)", "coord_radial(reverse)" + deprecate( + "4.0.0", "coord_radial(direction)", "coord_radial(reverse)", + when = "4.0.0", escalate = "warn" ) reverse <- switch(reverse, "r" = "thetar", "theta") } diff --git a/R/coord-transform.R b/R/coord-transform.R index 0154de5062..5f0c067ce6 100644 --- a/R/coord-transform.R +++ b/R/coord-transform.R @@ -84,11 +84,11 @@ coord_transform <- function(x = "identity", y = "identity", xlim = NULL, ylim = limx = deprecated(), limy = deprecated(), clip = "on", expand = TRUE, reverse = "none") { if (lifecycle::is_present(limx)) { - deprecate_warn0("3.3.0", "coord_transform(limx)", "coord_transform(xlim)") + deprecate("3.3.0", "coord_transform(limx)", "coord_transform(xlim)") xlim <- limx } if (lifecycle::is_present(limy)) { - deprecate_warn0("3.3.0", "coord_transform(limy)", "coord_transform(ylim)") + deprecate("3.3.0", "coord_transform(limy)", "coord_transform(ylim)") ylim <- limy } diff --git a/R/fortify-map.R b/R/fortify-map.R index 5dfc80850b..f8da994e7d 100644 --- a/R/fortify-map.R +++ b/R/fortify-map.R @@ -27,8 +27,8 @@ #' geom_polygon(aes(group = group), colour = "white") #' } fortify.map <- function(model, data, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), "map_data()" + deprecate( + "4.0.0", I("`fortify()`"), "map_data()", escalate = "warn" ) df <- data_frame0( long = model$x, diff --git a/R/fortify-models.R b/R/fortify-models.R index 3d61df71e0..47ad8790cb 100644 --- a/R/fortify-models.R +++ b/R/fortify-models.R @@ -38,8 +38,9 @@ #' ggplot(augment(mod, mtcars), aes(.fitted, .std.resid, colour = factor(cyl))) + #' geom_point() fortify.lm <- function(model, data = model$model, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), I("`broom::augment()`") + deprecate( + "4.0.0", escalate = "warn", + I("`fortify()`"), I("`broom::augment()`") ) infl <- stats::influence(model, do.coef = FALSE) data$.hat <- infl$hat @@ -101,8 +102,9 @@ NULL #' @rdname fortify-multcomp #' @export fortify.glht <- function(model, data, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), I("`broom::tidy()`") + deprecate( + "4.0.0", escalate = "warn", + I("`fortify()`"), I("`broom::tidy()`") ) base::data.frame( lhs = rownames(model$linfct), @@ -117,8 +119,9 @@ fortify.glht <- function(model, data, ...) { #' @method fortify confint.glht #' @export fortify.confint.glht <- function(model, data, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), I("`broom::tidy()`") + deprecate( + "4.0.0", escalate = "warn", + I("`fortify()`"), I("`broom::tidy()`") ) coef <- model$confint colnames(coef) <- to_lower_ascii(colnames(coef)) @@ -136,8 +139,9 @@ fortify.confint.glht <- function(model, data, ...) { #' @rdname fortify-multcomp #' @export fortify.summary.glht <- function(model, data, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), I("`broom::tidy()`") + deprecate( + "4.0.0", escalate = "warn", + I("`fortify()`"), I("`broom::tidy()`") ) coef <- as.data.frame( model$test[c("coefficients", "sigma", "tstat", "pvalues")]) @@ -157,8 +161,9 @@ fortify.summary.glht <- function(model, data, ...) { #' @rdname fortify-multcomp #' @export fortify.cld <- function(model, data, ...) { - lifecycle::deprecate_warn( - "4.0.0", I("`fortify()`"), I("`broom::tidy()`") + deprecate( + "4.0.0", escalate = "warn", + I("`fortify()`"), I("`broom::tidy()`") ) base::data.frame( lhs = names(model$mcletters$Letters), diff --git a/R/fortify-spatial.R b/R/fortify-spatial.R index 2bdcf06557..23cd08eccf 100644 --- a/R/fortify-spatial.R +++ b/R/fortify-spatial.R @@ -18,7 +18,8 @@ NULL #' @export #' @method fortify SpatialPolygonsDataFrame fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -45,7 +46,8 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) { #' @export #' @method fortify SpatialPolygons fortify.SpatialPolygons <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -61,7 +63,8 @@ fortify.SpatialPolygons <- function(model, data, ...) { #' @export #' @method fortify Polygons fortify.Polygons <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -85,7 +88,8 @@ fortify.Polygons <- function(model, data, ...) { #' @export #' @method fortify Polygon fortify.Polygon <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -101,7 +105,8 @@ fortify.Polygon <- function(model, data, ...) { #' @export #' @method fortify SpatialLinesDataFrame fortify.SpatialLinesDataFrame <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -114,7 +119,8 @@ fortify.SpatialLinesDataFrame <- function(model, data, ...) { #' @export #' @method fortify Lines fortify.Lines <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn", I("`fortify()`"), details = "Please migrate to sf." ) @@ -138,7 +144,8 @@ fortify.Lines <- function(model, data, ...) { #' @export #' @method fortify Line fortify.Line <- function(model, data, ...) { - deprecate_warn0("3.4.4", + deprecate( + "3.4.4", escalate = "warn",, I("`fortify()`"), details = "Please migrate to sf." ) diff --git a/R/geom-.R b/R/geom-.R index 339750450c..20649c7f2f 100644 --- a/R/geom-.R +++ b/R/geom-.R @@ -206,7 +206,7 @@ Geom <- ggproto( # Take care of subclasses setting the wrong default when inheriting from # a geom with rename_size = TRUE if (self$rename_size && is.null(default_aes$linewidth)) { - deprecate_warn0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere")) + deprecate("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere")) default_aes$linewidth <- default_aes$size } @@ -530,7 +530,7 @@ check_aesthetics <- function(x, n) { fix_linewidth <- function(data, name) { if (is.null(data$linewidth) && !is.null(data$size)) { - deprecate_warn0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic")) + deprecate("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic")) data$linewidth <- data$size } data diff --git a/R/geom-sf.R b/R/geom-sf.R index 177c30f933..4ee4af980b 100644 --- a/R/geom-sf.R +++ b/R/geom-sf.R @@ -329,7 +329,10 @@ geom_sf_label <- function(mapping = aes(), data = NULL, extra_args <- list2(...) if (lifecycle::is_present(label.size)) { - deprecate_warn0("3.5.0", "geom_label(label.size)", "geom_label(linewidth)") + deprecate( + "3.5.0", escalate = "warn", + "geom_label(label.size)", "geom_label(linewidth)" + ) extra_args$linewidth <- extra_args$linewidth %||% label.size } diff --git a/R/guide-axis-logticks.R b/R/guide-axis-logticks.R index 1a66637b31..65af2cfe84 100644 --- a/R/guide-axis-logticks.R +++ b/R/guide-axis-logticks.R @@ -82,20 +82,23 @@ guide_axis_logticks <- function( ... ) { if (lifecycle::is_present(prescale_base)) { - deprecate_warn0( - "3.5.1", "guide_axis_logticks(prescale_base)", "guide_axis_logticks(prescale.base)" + deprecate( + "3.5.1", escalate = "warn", + "guide_axis_logticks(prescale_base)", "guide_axis_logticks(prescale.base)" ) prescale.base <- prescale_base } if (lifecycle::is_present(negative_small)) { - deprecate_warn0( - "3.5.1", "guide_axis_logticks(negative_small)", "guide_axis_logticks(negative.small)" + deprecate( + "3.5.1", escalate = "warn", + "guide_axis_logticks(negative_small)", "guide_axis_logticks(negative.small)" ) negative.small <- negative_small } if (lifecycle::is_present(short_theme)) { - deprecate_warn0( - "3.5.1", "guide_axis_logticks(short_theme)", "guide_axis_logticks(short.theme)" + deprecate( + "3.5.1", escalate = "warn", + "guide_axis_logticks(short_theme)", "guide_axis_logticks(short.theme)" ) short.theme <- short_theme } diff --git a/R/guides-.R b/R/guides-.R index fa50f5a79d..8213ff6723 100644 --- a/R/guides-.R +++ b/R/guides-.R @@ -78,7 +78,7 @@ guides <- function(...) { idx_false <- vapply(args, isFALSE, FUN.VALUE = logical(1L)) if (isTRUE(any(idx_false))) { - deprecate_warn0("3.3.4", "guides(`` = 'cannot be `FALSE`. Use \"none\" instead')") + deprecate("3.3.4", "guides(`` = 'cannot be `FALSE`. Use \"none\" instead')") args[idx_false] <- "none" } @@ -345,7 +345,7 @@ Guides <- ggproto( default %||% missing if (isFALSE(guide)) { - deprecate_warn0("3.3.4", I("The `guide` argument in `scale_*()` cannot be `FALSE`. This "), I('"none"')) + deprecate("3.3.4", I("The `guide` argument in `scale_*()` cannot be `FALSE`. This "), I('"none"')) guide <- "none" } diff --git a/R/layer.R b/R/layer.R index 179f519441..296d58964c 100644 --- a/R/layer.R +++ b/R/layer.R @@ -149,7 +149,7 @@ layer <- function(geom = NULL, stat = NULL, if (geom$rename_size && "size" %in% extra_param && !"linewidth" %in% mapped_aesthetics(mapping)) { aes_params <- c(aes_params, params["size"]) extra_param <- setdiff(extra_param, "size") - deprecate_warn0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env) + deprecate("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env) } if (check.param && length(extra_param) > 0) { cli::cli_warn("Ignoring unknown parameters: {.arg {extra_param}}", call = call_env) @@ -162,7 +162,7 @@ layer <- function(geom = NULL, stat = NULL, # Take care of size->linewidth aes renaming if (geom$rename_size && "size" %in% extra_aes && !"linewidth" %in% mapped_aesthetics(mapping)) { extra_aes <- setdiff(extra_aes, "size") - deprecate_warn0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env) + deprecate("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`"), user_env = user_env) } if (check.aes && length(extra_aes) > 0) { cli::cli_warn("Ignoring unknown aesthetics: {.field {extra_aes}}", call = call_env) @@ -495,7 +495,7 @@ Layer <- ggproto("Layer", NULL, !"linewidth" %in% names(self$computed_mapping) && "linewidth" %in% self$geom$aesthetics()) { self$computed_mapping$size <- plot@mapping$size - deprecate_warn0("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`")) + deprecate("3.4.0", I("Using `size` aesthetic for lines"), I("`linewidth`")) } } else { self$computed_mapping <- self$mapping diff --git a/R/quick-plot.R b/R/quick-plot.R index 61e983843b..cad0241064 100644 --- a/R/quick-plot.R +++ b/R/quick-plot.R @@ -62,7 +62,7 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE, xlab = NULL, ylab = NULL, asp = NA, stat = deprecated(), position = deprecated()) { - deprecate_warn0("3.4.0", "qplot()") + deprecate("3.4.0", "qplot()") caller_env <- parent.frame() diff --git a/R/scale-expansion.R b/R/scale-expansion.R index 98a6915d9d..7b50059707 100644 --- a/R/scale-expansion.R +++ b/R/scale-expansion.R @@ -48,7 +48,7 @@ expansion <- function(mult = 0, add = 0) { #' @rdname expansion #' @export expand_scale <- function(mult = 0, add = 0) { - deprecate_warn0("3.3.0", "expand_scale()", "expansion()") + deprecate("3.3.0", "expand_scale()", "expansion()") expansion(mult, add) } diff --git a/R/stat-summary-bin.R b/R/stat-summary-bin.R index d86936163a..2f66afe57d 100644 --- a/R/stat-summary-bin.R +++ b/R/stat-summary-bin.R @@ -22,15 +22,15 @@ stat_summary_bin <- function(mapping = NULL, data = NULL, fun.ymin = deprecated(), fun.ymax = deprecated()) { if (lifecycle::is_present(fun.y)) { - deprecate_warn0("3.3.0", "stat_summary_bin(fun.y)", "stat_summary_bin(fun)") + deprecate("3.3.0", "stat_summary_bin(fun.y)", "stat_summary_bin(fun)") fun <- fun %||% fun.y } if (lifecycle::is_present(fun.ymin)) { - deprecate_warn0("3.3.0", "stat_summary_bin(fun.ymin)", "stat_summary_bin(fun.min)") + deprecate("3.3.0", "stat_summary_bin(fun.ymin)", "stat_summary_bin(fun.min)") fun.min <- fun.min %||% fun.ymin } if (lifecycle::is_present(fun.ymax)) { - deprecate_warn0("3.3.0", "stat_summary_bin(fun.ymax)", "stat_summary_bin(fun.max)") + deprecate("3.3.0", "stat_summary_bin(fun.ymax)", "stat_summary_bin(fun.max)") fun.max <- fun.max %||% fun.ymax } layer( diff --git a/R/stat-summary.R b/R/stat-summary.R index 789f867da9..6f84bd7ba1 100644 --- a/R/stat-summary.R +++ b/R/stat-summary.R @@ -142,15 +142,15 @@ stat_summary <- function(mapping = NULL, data = NULL, fun.ymin = deprecated(), fun.ymax = deprecated()) { if (lifecycle::is_present(fun.y)) { - deprecate_warn0("3.3.0", "stat_summary(fun.y)", "stat_summary(fun)") + deprecate("3.3.0", "stat_summary(fun.y)", "stat_summary(fun)") fun <- fun %||% fun.y } if (lifecycle::is_present(fun.ymin)) { - deprecate_warn0("3.3.0", "stat_summary(fun.ymin)", "stat_summary(fun.min)") + deprecate("3.3.0", "stat_summary(fun.ymin)", "stat_summary(fun.min)") fun.min <- fun.min %||% fun.ymin } if (lifecycle::is_present(fun.ymax)) { - deprecate_warn0("3.3.0", "stat_summary(fun.ymax)", "stat_summary(fun.max)") + deprecate("3.3.0", "stat_summary(fun.ymax)", "stat_summary(fun.max)") fun.max <- fun.max %||% fun.ymax } layer( diff --git a/R/theme-elements.R b/R/theme-elements.R index 73c545794e..3be36d388b 100644 --- a/R/theme-elements.R +++ b/R/theme-elements.R @@ -142,7 +142,7 @@ element_rect <- S7::new_class( inherit.blank = FALSE, size = deprecated(), ...){ warn_dots_empty() if (lifecycle::is_present(size)) { - deprecate_warn0("3.4.0", "element_rect(size)", "element_rect(linewidth)") + deprecate("3.4.0", "element_rect(size)", "element_rect(linewidth)") linewidth <- size } obj <- S7::new_object( @@ -177,7 +177,7 @@ element_line <- S7::new_class( inherit.blank = FALSE, size = deprecated(), ...) { warn_dots_empty() if (lifecycle::is_present(size)) { - deprecate_warn0("3.4.0", "element_line(size)", "element_line(linewidth)") + deprecate("3.4.0", "element_line(size)", "element_line(linewidth)") linewidth <- size } colour <- color %||% colour @@ -487,7 +487,7 @@ S7::method(element_grob, element_rect) <- ..., size = deprecated()) { if (lifecycle::is_present(size)) { - deprecate_warn0("3.4.0", "element_grob.element_rect(size)", "element_grob.element_rect(linewidth)") + deprecate("3.4.0", "element_grob.element_rect(size)", "element_grob.element_rect(linewidth)") linewidth <- size } @@ -539,7 +539,7 @@ S7::method(element_grob, element_line) <- default.units = "npc", id.lengths = NULL, ..., size = deprecated()) { if (lifecycle::is_present(size)) { - deprecate_warn0("3.4.0", "element_grob.element_line(size)", "element_grob.element_line(linewidth)") + deprecate("3.4.0", "element_grob.element_line(size)", "element_grob.element_line(linewidth)") linewidth <- size } diff --git a/R/utilities.R b/R/utilities.R index 5fda819f3d..735c81bfcb 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -212,7 +212,7 @@ pal_binned <- function(palette) { #' @keywords internal #' @export gg_dep <- function(version, msg) { - deprecate_warn0("3.3.0", "gg_dep()") + deprecate("3.3.0", "gg_dep()") .Deprecated() v <- as.package_version(version) cv <- utils::packageVersion("ggplot2") @@ -804,11 +804,6 @@ deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL, invisible() } -deprecate_warn0 <- function(..., user_env = NULL) { - user_env <- user_env %||% getOption("ggplot2_plot_env") %||% caller_env(2) - lifecycle::deprecate_warn(..., user_env = user_env) -} - as_unordered_factor <- function(x) { x <- as.factor(x) class(x) <- setdiff(class(x), "ordered") From d8fe8edf6cefe1628c2f154cbf518fc1e0ce487a Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 6 Nov 2025 10:31:25 +0100 Subject: [PATCH 5/5] prefix utils --- R/utilities.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/utilities.R b/R/utilities.R index 735c81bfcb..d59adc62ee 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -789,7 +789,7 @@ deprecate <- function(when, ..., id = NULL, always = FALSE, user_env = NULL, defunct <- "3.0.0" full <- "3.4.0" - soft <- packageVersion("ggplot2") + soft <- utils::packageVersion("ggplot2") version <- as.package_version(when) if (version < defunct || identical(escalate, "abort")) {