From 349d440857d369501209acec8e4093fe123169b8 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Thu, 18 Apr 2024 20:08:33 -0300 Subject: [PATCH 1/9] chore: Update deprecation warnings in ggally_cor function --- NEWS.md | 2 ++ R/gg-plots.R | 23 ++++++++++++++++------- man/ggally_cor.Rd | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 12445271a..5b5b511b4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # GGally (development version) +* Use lifecycle for deprecation warnings (#494, #496) + # GGally 2.2.1 * Fix compatibility with ggplot2 3.5.0 (@teunbrand, #481) diff --git a/R/gg-plots.R b/R/gg-plots.R index 588722f29..1cbbcab95 100644 --- a/R/gg-plots.R +++ b/R/gg-plots.R @@ -261,10 +261,11 @@ ggally_density <- function(data, mapping, ...) { #' @param group_args arguments being supplied to the split-by-color group's \code{\link[ggplot2]{geom_text}()} #' @param justify_labels \code{justify} argument supplied when \code{\link[base]{format}}ting the labels #' @param align_percent relative align position of the text. When \code{justify_labels = 0.5}, this should not be needed to be set. -#' @param alignPercent,displayGrid deprecated. Please use their snake-case counterparts. +#' @param alignPercent,displayGrid `r lifecycle::badge("deprecated")`. Please use their snake-case counterparts. #' @param title title text to be displayed #' @author Barret Schloerke #' @importFrom stats complete.cases cor +#' @importFrom lifecycle deprecated #' @seealso \code{\link{ggally_statistic}}, \code{\link{ggally_cor_v1_5}} #' @export #' @keywords hplot @@ -308,14 +309,22 @@ ggally_cor <- function( justify_labels = "right", align_percent = 0.5, title = "Corr", - alignPercent = warning("deprecated. Use `align_percent`"), - displayGrid = warning("deprecated. Use `display_grid`")) { - if (!missing(alignPercent)) { - warning("`alignPercent` is deprecated. Please use `align_percent` if alignment still needs to be adjusted") + alignPercent = deprecated(), + displayGrid = deprecated()) { + if (lifecycle::is_present(alignPercent)) { + lifecycle::deprecate_soft( + when = "2.2.2", + what = "ggally_cor(alignPercent)", + details = "Please use `align_percent` if alignment still needs to be adjusted." + ) align_percent <- alignPercent } - if (!missing(displayGrid)) { - warning("`displayGrid` is deprecated. Please use `display_grid`") + if (lifecycle::is_present(displayGrid)) { + lifecycle::deprecate_soft( + when = "2.2.2", + what = "ggally_cor(displayGrid)", + details = "Please use `display_grid`" + ) display_grid <- displayGrid } diff --git a/man/ggally_cor.Rd b/man/ggally_cor.Rd index 13a33a789..cc361f863 100644 --- a/man/ggally_cor.Rd +++ b/man/ggally_cor.Rd @@ -18,8 +18,8 @@ ggally_cor( justify_labels = "right", align_percent = 0.5, title = "Corr", - alignPercent = warning("deprecated. Use `align_percent`"), - displayGrid = warning("deprecated. Use `display_grid`") + alignPercent = deprecated(), + displayGrid = deprecated() ) } \arguments{ @@ -55,7 +55,7 @@ ggally_cor( \item{title}{title text to be displayed} -\item{alignPercent, displayGrid}{deprecated. Please use their snake-case counterparts.} +\item{alignPercent, displayGrid}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}. Please use their snake-case counterparts.} } \description{ Estimate correlation from the given data. If a color variable is supplied, the correlation will also be calculated per group. From abe82d8bff96aa35512126b5d9f6b5edd7cceb9e Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Mon, 22 Apr 2024 19:38:05 -0300 Subject: [PATCH 2/9] Update v1_ggmatrix_theme deprecation warning --- R/deprecated.R | 36 +++++++++++++++++++++++++++-- man/v1_ggmatrix_theme.Rd | 29 +++++++++++++++++++++-- tests/testthat/_snaps/deprecated.md | 22 ++++++++++++++++++ tests/testthat/test-deprecated.R | 6 +++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 tests/testthat/_snaps/deprecated.md diff --git a/R/deprecated.R b/R/deprecated.R index c81a507bf..c79d69b57 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -1,16 +1,48 @@ #' Modify a \code{\link{ggmatrix}} object by adding an \pkg{ggplot2} object to all +#' @description +#' `r lifecycle::badge("deprecated")` #' -# \lifecycle{deprecated} +#' This function allows cleaner axis labels for your plots, but is deprecated. +#' You can achieve the same effect by specifying strip's background and placement +#' properties (see Examples). +#' +#' @keywords internal #' #' @export #' @examples #' # Small function to display plots only if it's interactive #' p_ <- GGally::print_if_interactive #' +#' # Cleaner axis labels with v1_ggmatrix_theme #' p_(ggpairs(iris, 1:2) + v1_ggmatrix_theme()) -#' # move the column names to the left and bottom +#' +#' # Move the column names to the left and bottom #' p_(ggpairs(iris, 1:2, switch = "both") + v1_ggmatrix_theme()) +#' +#' # Manually specifying axis labels properties +#' p_( +#' ggpairs(iris, 1:2) + +#' theme( +#' strip.background = element_rect(fill = "white"), +#' strip.placement = "outside" +#' ) +#') +#' +#' # This way you have even more control over how the final plot looks. +#' # For example, if you want to set the background color to yellow: +#' p_( +#' ggpairs(iris, 1:2) + +#' theme( +#' strip.background = element_rect(fill = "yellow"), +#' strip.placement = "outside" +#' ) +#') v1_ggmatrix_theme <- function() { + lifecycle::deprecate_soft( + when = "2.2.2", + what = "v1_ggmatrix_theme()", + details = "This function will be removed in future releases." + ) theme( strip.background = element_rect(fill = "white"), strip.placement = "outside" diff --git a/man/v1_ggmatrix_theme.Rd b/man/v1_ggmatrix_theme.Rd index 87e8ed474..c65ebe6eb 100644 --- a/man/v1_ggmatrix_theme.Rd +++ b/man/v1_ggmatrix_theme.Rd @@ -7,13 +7,38 @@ v1_ggmatrix_theme() } \description{ -Modify a \code{\link{ggmatrix}} object by adding an \pkg{ggplot2} object to all +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +This function allows cleaner axis labels for your plots, but is deprecated. +You can achieve the same effect by specifying strip's background and placement +properties (see Examples). } \examples{ # Small function to display plots only if it's interactive p_ <- GGally::print_if_interactive +# Cleaner axis labels with v1_ggmatrix_theme p_(ggpairs(iris, 1:2) + v1_ggmatrix_theme()) -# move the column names to the left and bottom + +# Move the column names to the left and bottom p_(ggpairs(iris, 1:2, switch = "both") + v1_ggmatrix_theme()) + +# Manually specifying axis labels properties +p_( + ggpairs(iris, 1:2) + + theme( + strip.background = element_rect(fill = "white"), + strip.placement = "outside" + ) +) + +# This way you have even more control over how the final plot looks. +# For example, if you want to set the background color to yellow: +p_( + ggpairs(iris, 1:2) + + theme( + strip.background = element_rect(fill = "yellow"), + strip.placement = "outside" + ) +) } diff --git a/tests/testthat/_snaps/deprecated.md b/tests/testthat/_snaps/deprecated.md new file mode 100644 index 000000000..76ba7ca1b --- /dev/null +++ b/tests/testthat/_snaps/deprecated.md @@ -0,0 +1,22 @@ +# v1_ggmatrix_theme is deprecated + + Code + v1_ggmatrix_theme() + Condition + Warning: + `v1_ggmatrix_theme()` was deprecated in GGally 2.2.2. + i This function will be removed in future releases. + Output + List of 2 + $ strip.background:List of 5 + ..$ fill : chr "white" + ..$ colour : NULL + ..$ linewidth : NULL + ..$ linetype : NULL + ..$ inherit.blank: logi FALSE + ..- attr(*, "class")= chr [1:2] "element_rect" "element" + $ strip.placement : chr "outside" + - attr(*, "class")= chr [1:2] "theme" "gg" + - attr(*, "complete")= logi FALSE + - attr(*, "validate")= logi TRUE + diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index d573db1c1..eaaa9c1c0 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -6,3 +6,9 @@ test_that("ggally-cor", { p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) ) }) + +test_that("v1_ggmatrix_theme is deprecated", { + expect_snapshot( + v1_ggmatrix_theme() + ) +}) From 7ec5651ed6e2f6204e3f9ae8a6d2a17669be3049 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Mon, 22 Apr 2024 20:13:20 -0300 Subject: [PATCH 3/9] Update ggally_cor_v1_5() deprecation warning --- DESCRIPTION | 3 ++- R/deprecated.R | 16 ++++++++++++---- man/ggally_cor_v1_5.Rd | 10 +++++++--- man/v1_ggmatrix_theme.Rd | 1 + tests/testthat/_snaps/deprecated.md | 12 +++++++++++- tests/testthat/test-deprecated.R | 12 +++++++++--- 6 files changed, 42 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b259721b..8a84f972e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -69,7 +69,8 @@ Suggests: knitr, spelling, emmeans, - vdiffr + vdiffr, + withr (>= 3.0.0) Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 SystemRequirements: openssl diff --git a/R/deprecated.R b/R/deprecated.R index c79d69b57..78604781e 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -52,12 +52,15 @@ v1_ggmatrix_theme <- function() { #' Correlation value plot #' -# \lifecycle{deprecated} -#' -#' (Deprecated. See \code{\link{ggally_cor}}.) +#' @description +#' `r lifecycle::badge("deprecated")` #' #' Estimate correlation from the given data. #' +#' This function is deprecated and will be removed in future releases. +#' +#' See \code{\link{ggally_cor}}. +#' #' @param data data set using #' @param mapping aesthetics being used #' @param alignPercent right align position of numbers. Default is 60 percent across the horizontal @@ -72,7 +75,7 @@ v1_ggmatrix_theme <- function() { #' @importFrom stats complete.cases cor #' @seealso \code{\link{ggally_cor}} #' @export -#' @keywords hplot +#' @keywords hplot internal #' @examples #' # Small function to display plots only if it's interactive #' p_ <- GGally::print_if_interactive @@ -109,6 +112,11 @@ ggally_cor_v1_5 <- function( corAlignPercent = NULL, corMethod = NULL, corUse = NULL, displayGrid = TRUE, ...) { + lifecycle::deprecate_soft( + when = "2.2.2", + what = "ggally_cor_v1_5()", + with = "ggally_cor()" + ) if (!is.null(corAlignPercent)) { stop("'corAlignPercent' is deprecated. Please use argument 'alignPercent'") } diff --git a/man/ggally_cor_v1_5.Rd b/man/ggally_cor_v1_5.Rd index 1b3130497..8ab7ca2de 100644 --- a/man/ggally_cor_v1_5.Rd +++ b/man/ggally_cor_v1_5.Rd @@ -39,10 +39,13 @@ ggally_cor_v1_5( \item{...}{other arguments being supplied to geom_text} } \description{ -(Deprecated. See \code{\link{ggally_cor}}.) -} -\details{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + Estimate correlation from the given data. + +This function is deprecated and will be removed in future releases. + +See \code{\link{ggally_cor}}. } \examples{ # Small function to display plots only if it's interactive @@ -80,3 +83,4 @@ p_(ggally_cor_v1_5( Barret Schloerke } \keyword{hplot} +\keyword{internal} diff --git a/man/v1_ggmatrix_theme.Rd b/man/v1_ggmatrix_theme.Rd index c65ebe6eb..a2e2d2e09 100644 --- a/man/v1_ggmatrix_theme.Rd +++ b/man/v1_ggmatrix_theme.Rd @@ -42,3 +42,4 @@ p_( ) ) } +\keyword{internal} diff --git a/tests/testthat/_snaps/deprecated.md b/tests/testthat/_snaps/deprecated.md index 76ba7ca1b..d0090d001 100644 --- a/tests/testthat/_snaps/deprecated.md +++ b/tests/testthat/_snaps/deprecated.md @@ -1,4 +1,4 @@ -# v1_ggmatrix_theme is deprecated +# v1_ggmatrix_theme() is deprecated Code v1_ggmatrix_theme() @@ -20,3 +20,13 @@ - attr(*, "complete")= logi FALSE - attr(*, "validate")= logi TRUE +# ggally_cor_v1_5() is deprecated + + Code + p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name( + "tip"))) + Condition + Warning: + `ggally_cor_v1_5()` was deprecated in GGally 2.2.2. + i Please use `ggally_cor()` instead. + diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index eaaa9c1c0..0a6d0adf9 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -1,14 +1,20 @@ - data(tips) -test_that("ggally-cor", { +test_that("ggally_cor_v1_5() works", { + withr::local_options(lifecycle_verbosity = "quiet") expect_silent( p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) ) }) -test_that("v1_ggmatrix_theme is deprecated", { +test_that("v1_ggmatrix_theme() is deprecated", { expect_snapshot( v1_ggmatrix_theme() ) }) + +test_that("ggally_cor_v1_5() is deprecated", { + expect_snapshot( + p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) + ) +}) From 99cb24e8141e9da0ed9bc606158552150e2791f6 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Mon, 22 Apr 2024 21:10:08 -0300 Subject: [PATCH 4/9] Expect warning when testing v1_ggmatrix_theme in test-ggmatrix_add.R --- tests/testthat/_snaps/ggmatrix_add.md | 13 +++++++++++++ tests/testthat/test-ggmatrix_add.R | 12 ++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/testthat/_snaps/ggmatrix_add.md diff --git a/tests/testthat/_snaps/ggmatrix_add.md b/tests/testthat/_snaps/ggmatrix_add.md new file mode 100644 index 000000000..de8f22a23 --- /dev/null +++ b/tests/testthat/_snaps/ggmatrix_add.md @@ -0,0 +1,13 @@ +# v1_ggmatrix_theme + + Code + pm <- ggpairs(tips, 1:2) + pm1 <- pm + v1_ggmatrix_theme() + Condition + Warning: + `v1_ggmatrix_theme()` was deprecated in GGally 2.2.2. + i This function will be removed in future releases. + Code + expect_true(is.null(pm$gg)) + expect_true(!is.null(pm1$gg)) + diff --git a/tests/testthat/test-ggmatrix_add.R b/tests/testthat/test-ggmatrix_add.R index c085e972e..7c2411af3 100644 --- a/tests/testthat/test-ggmatrix_add.R +++ b/tests/testthat/test-ggmatrix_add.R @@ -50,10 +50,14 @@ test_that("add_list", { }) test_that("v1_ggmatrix_theme", { - pm <- ggpairs(tips, 1:2) + expect_snapshot( + { + pm <- ggpairs(tips, 1:2) - pm1 <- pm + v1_ggmatrix_theme() + pm1 <- pm + v1_ggmatrix_theme() - expect_true(is.null(pm$gg)) - expect_true(!is.null(pm1$gg)) + expect_true(is.null(pm$gg)) + expect_true(!is.null(pm1$gg)) + } + ) }) From fee9c6099793e23107bf252edc70d8a00b4770d2 Mon Sep 17 00:00:00 2001 From: Andrei <92amartins@gmail.com> Date: Wed, 24 Apr 2024 18:33:17 -0300 Subject: [PATCH 5/9] Update R/deprecated.R Co-authored-by: Barret Schloerke --- R/deprecated.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/deprecated.R b/R/deprecated.R index 78604781e..85a3163ce 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -75,7 +75,7 @@ v1_ggmatrix_theme <- function() { #' @importFrom stats complete.cases cor #' @seealso \code{\link{ggally_cor}} #' @export -#' @keywords hplot internal +#' @keywords internal #' @examples #' # Small function to display plots only if it's interactive #' p_ <- GGally::print_if_interactive From 17bbdc411b3b3ebaf13bc5fdd00cc3bb1a97c6e7 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Wed, 24 Apr 2024 19:40:40 -0300 Subject: [PATCH 6/9] Deprecate params in ggnet function --- R/ggnet.R | 67 +++++++++++++++++++++++++------------ man/ggally_cor_v1_5.Rd | 1 - man/ggnet.Rd | 20 +++++------ tests/testthat/test-ggnet.R | 10 +++--- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/R/ggnet.R b/R/ggnet.R index a453a1b74..8fa72decd 100644 --- a/R/ggnet.R +++ b/R/ggnet.R @@ -114,12 +114,12 @@ if (getRversion() >= "2.15.1") { #' @param legend.position the location of the plot legend(s). Accepts all #' \code{legend.position} values supported by \code{\link[ggplot2]{theme}}. #' Defaults to \code{"right"}. -#' @param names deprecated: see \code{group.legend} and \code{size.legend} -#' @param quantize.weights deprecated: see \code{weight.cut} -#' @param subset.threshold deprecated: see \code{weight.min} -#' @param top8.nodes deprecated: this functionality was experimental and has +#' @param names `r lifecycle::badge("deprecated")` see \code{group.legend} and \code{size.legend} +#' @param quantize.weights `r lifecycle::badge("deprecated")` see \code{weight.cut} +#' @param subset.threshold `r lifecycle::badge("deprecated")` see \code{weight.min} +#' @param top8.nodes `r lifecycle::badge("deprecated")` this functionality was experimental and has #' been removed entirely from \code{ggnet} -#' @param trim.labels deprecated: see \code{label.trim} +#' @param trim.labels `r lifecycle::badge("deprecated")` see \code{label.trim} #' @param ... other arguments passed to the \code{geom_text} object that sets #' the node labels: see \code{\link[ggplot2]{geom_text}} for details. #' @seealso \code{\link{ggnet2}} in this package, @@ -199,11 +199,11 @@ ggnet <- function( legend.size = 9, legend.position = "right", # -- deprecated arguments ---------------------------------------------------- - names = c("", ""), - quantize.weights = FALSE, - subset.threshold = 0, - top8.nodes = FALSE, - trim.labels = FALSE, + names = deprecated(), + quantize.weights = deprecated(), + subset.threshold = deprecated(), + top8.nodes = deprecated(), + trim.labels = deprecated(), ... ) { @@ -213,32 +213,55 @@ ggnet <- function( # -- deprecations ------------------------------------------------------------ if (length(mode) == 1 && mode == "geo") { - warning("mode = 'geo' is deprecated; please use mode = c('lon', 'lat') instead") + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(mode='cannot be `geo`')", + details = "Please use mode = c('lon', 'lat') instead" + ) mode = c("lon", "lat") } - if (!identical(names, c("", ""))) { - warning("names is deprecated; please use group.legend and size.legend instead") + if (lifecycle::is_present(names)) { + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(names)", + details = "Please use group.legend and size.legend instead" + ) group.legend = names[1] size.legend = names[2] } - if (isTRUE(quantize.weights)) { - warning("quantize.weights is deprecated; please use weight.cut instead") - weight.cut = TRUE + if (lifecycle::is_present(quantize.weights)) { + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(quantize.weights)", + details = "Please use weight.cut instead" + ) + weight.cut = quantize.weights } - if (subset.threshold > 0) { - warning("subset.threshold is deprecated; please use weight.min instead") + if (lifecycle::is_present(subset.threshold)) { + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(subset.threshold)", + details = "Please use weight.min instead" + ) weight.min = subset.threshold } - if (isTRUE(top8.nodes)) { - warning("top8.nodes is deprecated") + if (lifecycle::is_present(top8.nodes)) { + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(top8.nodes)" + ) } - if (isTRUE(trim.labels)) { - warning("trim.labels is deprecated; please use label.trim instead") + if (lifecycle::is_present(trim.labels)) { + lifecycle::deprecate_warn( + when = "2.2.2", + what = "ggnet(trim.labels)", + details = "Please use label.trim instead" + ) label.trim = function(x) gsub("^@|^http://(www\\.)?|/$", "", x) } diff --git a/man/ggally_cor_v1_5.Rd b/man/ggally_cor_v1_5.Rd index 8ab7ca2de..1159e3626 100644 --- a/man/ggally_cor_v1_5.Rd +++ b/man/ggally_cor_v1_5.Rd @@ -82,5 +82,4 @@ p_(ggally_cor_v1_5( \author{ Barret Schloerke } -\keyword{hplot} \keyword{internal} diff --git a/man/ggnet.Rd b/man/ggnet.Rd index e371d9061..d10847d0b 100644 --- a/man/ggnet.Rd +++ b/man/ggnet.Rd @@ -35,11 +35,11 @@ ggnet( label.trim = FALSE, legend.size = 9, legend.position = "right", - names = c("", ""), - quantize.weights = FALSE, - subset.threshold = 0, - top8.nodes = FALSE, - trim.labels = FALSE, + names = deprecated(), + quantize.weights = deprecated(), + subset.threshold = deprecated(), + top8.nodes = deprecated(), + trim.labels = deprecated(), ... ) } @@ -177,16 +177,16 @@ Defaults to \code{9}.} \code{legend.position} values supported by \code{\link[ggplot2]{theme}}. Defaults to \code{"right"}.} -\item{names}{deprecated: see \code{group.legend} and \code{size.legend}} +\item{names}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} see \code{group.legend} and \code{size.legend}} -\item{quantize.weights}{deprecated: see \code{weight.cut}} +\item{quantize.weights}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} see \code{weight.cut}} -\item{subset.threshold}{deprecated: see \code{weight.min}} +\item{subset.threshold}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} see \code{weight.min}} -\item{top8.nodes}{deprecated: this functionality was experimental and has +\item{top8.nodes}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} this functionality was experimental and has been removed entirely from \code{ggnet}} -\item{trim.labels}{deprecated: see \code{label.trim}} +\item{trim.labels}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} see \code{label.trim}} \item{...}{other arguments passed to the \code{geom_text} object that sets the node labels: see \code{\link[ggplot2]{geom_text}} for details.} diff --git a/tests/testthat/test-ggnet.R b/tests/testthat/test-ggnet.R index 23f37fab8..589749e58 100644 --- a/tests/testthat/test-ggnet.R +++ b/tests/testthat/test-ggnet.R @@ -49,10 +49,10 @@ test_that("examples", { xy <- gplot.layout.circle(n) # nolint n %v% "lon" <- xy[, 1] n %v% "lat" <- xy[, 2] - expect_warning(ggnet(n, mode = "geo"), "deprecated") + lifecycle::expect_deprecated(ggnet(n, mode = "geo")) # test names = c(x, y) - expect_warning(ggnet(n, names = c("a", "b")), "deprecated") + lifecycle::expect_deprecated(ggnet(n, names = c("a", "b"))) # test quantize.weights with_options(list(warn = 2), { @@ -62,14 +62,14 @@ test_that("examples", { # test subset.threshold suppressMessages({ - expect_warning(ggnet(n, subset.threshold = 2)) + lifecycle::expect_deprecated(ggnet(n, subset.threshold = 2)) }) # test top8.nodes - expect_warning(ggnet(n, top8.nodes = TRUE)) + lifecycle::expect_deprecated(ggnet(n, top8.nodes = TRUE)) # test trim.labels - expect_warning(ggnet(n, trim.labels = TRUE)) + lifecycle::expect_deprecated(ggnet(n, trim.labels = TRUE)) # # test subset.threshold by removing all nodes # expect_warning( From 75224360000e232b5ae0c3e887f5e388c495e684 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Wed, 24 Apr 2024 19:49:00 -0300 Subject: [PATCH 7/9] Deprecate ggnet function in favor of ggnet2 --- R/ggnet.R | 5 +++++ man/ggnet.Rd | 3 +++ 2 files changed, 8 insertions(+) diff --git a/R/ggnet.R b/R/ggnet.R index 8fa72decd..2136848eb 100644 --- a/R/ggnet.R +++ b/R/ggnet.R @@ -4,6 +4,9 @@ if (getRversion() >= "2.15.1") { #' Network plot #' +#' @description +#' `r lifecycle::badge("deprecated")` +#' #' Function for plotting network objects using \pkg{ggplot2}, now replaced by the #' \code{\link{ggnet2}} function, which provides additional control over #' plotting parameters. Please visit \url{https://github.com/briatte/ggnet} for @@ -135,6 +138,7 @@ if (getRversion() >= "2.15.1") { #' @importFrom stats quantile na.omit #' @importFrom utils head installed.packages #' @importFrom grDevices gray.colors +#' @keywords internal #' @examples #' # Small function to display plots only if it's interactive #' p_ <- GGally::print_if_interactive @@ -206,6 +210,7 @@ ggnet <- function( trim.labels = deprecated(), ... ) { + lifecycle::deprecate_soft("2.2.2", "ggnet()", "ggnet2()") # -- packages ---------------------------------------------------------------- diff --git a/man/ggnet.Rd b/man/ggnet.Rd index d10847d0b..7d5174b61 100644 --- a/man/ggnet.Rd +++ b/man/ggnet.Rd @@ -192,6 +192,8 @@ been removed entirely from \code{ggnet}} the node labels: see \code{\link[ggplot2]{geom_text}} for details.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + Function for plotting network objects using \pkg{ggplot2}, now replaced by the \code{\link{ggnet2}} function, which provides additional control over plotting parameters. Please visit \url{https://github.com/briatte/ggnet} for @@ -247,3 +249,4 @@ package Moritz Marbach and Francois Briatte, with help from Heike Hofmann, Pedro Jordano and Ming-Yu Liu } +\keyword{internal} From 7e0adb0bfcb55323bfa444882b4f005ff7274459 Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Wed, 24 Apr 2024 20:12:51 -0300 Subject: [PATCH 8/9] Update ggally_cor_v1_5 test --- DESCRIPTION | 3 +-- tests/testthat/test-deprecated.R | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8a84f972e..5b259721b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -69,8 +69,7 @@ Suggests: knitr, spelling, emmeans, - vdiffr, - withr (>= 3.0.0) + vdiffr Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 SystemRequirements: openssl diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index 0a6d0adf9..7b48a5ac8 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -1,9 +1,10 @@ data(tips) test_that("ggally_cor_v1_5() works", { - withr::local_options(lifecycle_verbosity = "quiet") - expect_silent( - p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) + lifecycle::expect_deprecated( + { + p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) + } ) }) From e9a7f1b7e7433bbcd3bad9e4888b54e8089a8e9c Mon Sep 17 00:00:00 2001 From: Andrei Martins <92amartins@gmail.com> Date: Wed, 24 Apr 2024 20:37:04 -0300 Subject: [PATCH 9/9] Update deprecation warnings in ggmatrix_gtable function --- R/ggmatrix_gtable.R | 8 ++++++-- man/ggmatrix_gtable.Rd | 2 +- tests/testthat/test-ggmatrix.R | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/R/ggmatrix_gtable.R b/R/ggmatrix_gtable.R index c63631a27..372e6591e 100644 --- a/R/ggmatrix_gtable.R +++ b/R/ggmatrix_gtable.R @@ -4,7 +4,7 @@ #' #' @param pm \code{\link{ggmatrix}} object to be plotted #' @param ... ignored -#' @param progress,progress_format Please use the 'progress' parameter in your \code{\link{ggmatrix}}-like function. See \code{\link{ggmatrix_progress}} for a few examples. These parameters will soon be deprecated. +#' @param progress,progress_format `r lifecycle::badge("deprecated")` Please use the 'progress' parameter in your \code{\link{ggmatrix}}-like function. See \code{\link{ggmatrix_progress}} for a few examples. #' @author Barret Schloerke #' @importFrom grid gpar grid.layout grid.newpage grid.text grid.rect popViewport pushViewport viewport grid.draw #' @export @@ -25,7 +25,11 @@ ggmatrix_gtable <- function( hasProgressBar <- !isFALSE(pm$progress) progress_fn <- pm$progress } else { - warning("Please use the 'progress' parameter in your ggmatrix-like function call. See ?ggmatrix_progress for a few examples. ggmatrix_gtable 'progress' and 'progress_format' will soon be deprecated.", immediate = TRUE) + lifecycle::deprecate_soft( + when = "2.2.2", + what = I("`progress` and `progress_format`"), + details = "Please use the 'progress' parameter in your ggmatrix-like function call. See ?ggmatrix_progress for a few examples." + ) # has progress variable defined # overrides pm$progress diff --git a/man/ggmatrix_gtable.Rd b/man/ggmatrix_gtable.Rd index 5a474d11a..8bed9c566 100644 --- a/man/ggmatrix_gtable.Rd +++ b/man/ggmatrix_gtable.Rd @@ -16,7 +16,7 @@ ggmatrix_gtable( \item{...}{ignored} -\item{progress, progress_format}{Please use the 'progress' parameter in your \code{\link{ggmatrix}}-like function. See \code{\link{ggmatrix_progress}} for a few examples. These parameters will soon be deprecated.} +\item{progress, progress_format}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Please use the 'progress' parameter in your \code{\link{ggmatrix}}-like function. See \code{\link{ggmatrix_progress}} for a few examples.} } \description{ Specialized method to print the \code{\link{ggmatrix}} object. diff --git a/tests/testthat/test-ggmatrix.R b/tests/testthat/test-ggmatrix.R index 0dd714c03..198ce670d 100644 --- a/tests/testthat/test-ggmatrix.R +++ b/tests/testthat/test-ggmatrix.R @@ -155,10 +155,10 @@ test_that("ggmatrix_gtable progress", { expect_silent({ pg <- ggmatrix_gtable(pm) }) - expect_warning({ + lifecycle::expect_deprecated({ ggmatrix_gtable(pm, progress = TRUE) }) - expect_warning({ + lifecycle::expect_deprecated({ ggmatrix_gtable(pm, progress_format = "asdfasdf :plot_i") }) })