From eca03a078a8cb4872b29566dc1afae620bc93f77 Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Mon, 13 May 2024 14:32:18 -0400 Subject: [PATCH 1/3] Add lifecycle deprecation badges/warnings (#867) Closes #866 --- .pre-commit-config.yaml | 1 + DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 2 ++ R/colby_constructors.R | 17 ++++++++---- R/package.R | 1 + R/tree_accessors.R | 16 +++++------ R/tt_compatibility.R | 33 ++++++++++++++++------- R/tt_dotabulation.R | 2 +- man/build_table.Rd | 2 +- man/figures/lifecycle-archived.svg | 21 +++++++++++++++ man/figures/lifecycle-defunct.svg | 21 +++++++++++++++ man/figures/lifecycle-deprecated.svg | 21 +++++++++++++++ man/figures/lifecycle-experimental.svg | 21 +++++++++++++++ man/figures/lifecycle-maturing.svg | 21 +++++++++++++++ man/figures/lifecycle-questioning.svg | 21 +++++++++++++++ man/figures/lifecycle-soft-deprecated.svg | 21 +++++++++++++++ man/figures/lifecycle-stable.svg | 29 ++++++++++++++++++++ man/figures/lifecycle-superseded.svg | 21 +++++++++++++++ man/insert_rrow.Rd | 5 +++- man/rbind.Rd | 6 ++++- tests/testthat/test-binding.R | 4 +-- tests/testthat/test-deprecated.R | 6 ++--- 23 files changed, 262 insertions(+), 33 deletions(-) create mode 100644 man/figures/lifecycle-archived.svg create mode 100644 man/figures/lifecycle-defunct.svg create mode 100644 man/figures/lifecycle-deprecated.svg create mode 100644 man/figures/lifecycle-experimental.svg create mode 100644 man/figures/lifecycle-maturing.svg create mode 100644 man/figures/lifecycle-questioning.svg create mode 100644 man/figures/lifecycle-soft-deprecated.svg create mode 100644 man/figures/lifecycle-stable.svg create mode 100644 man/figures/lifecycle-superseded.svg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8996c9173..64f6f0a76 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,7 @@ repos: - methods - checkmate - htmltools + - lifecycle - stats - stringi - id: use-tidy-description diff --git a/DESCRIPTION b/DESCRIPTION index 64fcdc474..301f88678 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,6 +36,7 @@ Depends: Imports: checkmate (>= 2.1.0), htmltools (>= 0.5.4), + lifecycle (>= 0.2.0), stats, stringi (>= 1.6) Suggests: @@ -44,7 +45,6 @@ Suggests: dplyr (>= 1.0.5), flextable (>= 0.8.4), knitr (>= 1.42), - lifecycle (>= 0.2.0), officer (>= 0.5.0), r2rtf (>= 0.3.2), rmarkdown (>= 2.19), diff --git a/NAMESPACE b/NAMESPACE index b207dee29..63e320dec 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -288,6 +288,7 @@ importFrom(formatters,export_as_pdf) importFrom(formatters,export_as_txt) importFrom(htmltools,tagList) importFrom(htmltools,tags) +importFrom(lifecycle,deprecated) importFrom(magrittr,"%>%") importFrom(stats,binom.test) importFrom(stats,na.omit) diff --git a/NEWS.md b/NEWS.md index a0da1b59c..498590b92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,8 @@ ### Miscellaneous * Removed deprecated functions `add_analyzed_var` and `trim_zero_rows`. + * Added `lifecycle` badge files for documentation. + * Deprecated the `gap` and `check_headers` arguments to `rbindl_rtables` using `lifecycle`. ## rtables 0.6.6 ### New Features diff --git a/R/colby_constructors.R b/R/colby_constructors.R index d7105a93d..fc43a32d7 100644 --- a/R/colby_constructors.R +++ b/R/colby_constructors.R @@ -46,7 +46,12 @@ setGeneric( #' @rdname int_methods setMethod("split_rows", "NULL", function(lyt, spl, pos, cmpnd_fun = AnalyzeMultiVars) { - .Deprecated(msg = "Initializing layouts via NULL is deprecated, please use basic_table() instead") + lifecycle::deprecate_warn( + when = "0.3.8", + what = I("split_rows(NULL)"), + with = "basic_table()", + details = "Initializing layouts via `NULL` is no longer supported." + ) rl <- PreDataRowLayout(SplitVector(spl)) cl <- PreDataColLayout() PreDataTableLayouts(rlayout = rl, clayout = cl) @@ -208,10 +213,12 @@ setGeneric( #' @rdname int_methods setMethod("split_cols", "NULL", function(lyt, spl, pos) { - .Deprecated(msg = paste( - "Initializing layouts via NULL is deprecated,", - "please use basic_table() instead" - )) + lifecycle::deprecate_warn( + when = "0.3.8", + what = I("split_cols(NULL)"), + with = "basic_table()", + details = "Initializing layouts via `NULL` is no longer supported." + ) cl <- PreDataColLayout(SplitVector(spl)) rl <- PreDataRowLayout() PreDataTableLayouts(rlayout = rl, clayout = cl) diff --git a/R/package.R b/R/package.R index 53c42924a..8b79f426b 100644 --- a/R/package.R +++ b/R/package.R @@ -4,6 +4,7 @@ #' @importFrom utils head head.matrix tail tail.matrix #' @importFrom stats setNames na.omit prop.test binom.test relevel quantile #' @importFrom htmltools tags tagList +#' @importFrom lifecycle deprecated #' @importFrom magrittr %>% #' @import methods NULL diff --git a/R/tree_accessors.R b/R/tree_accessors.R index 8b447db58..312f4fb1f 100644 --- a/R/tree_accessors.R +++ b/R/tree_accessors.R @@ -3001,10 +3001,10 @@ setGeneric("col_fnotes_here", function(obj) standardGeneric("col_fnotes_here")) #' @export #' @rdname ref_fnotes setMethod("col_fnotes_here", "ANY", function(obj) { - .Deprecated( - new = "col_footnotes", - old = "col_fnotes_here", - msg = "col_fnotes_here was deprecated in {rtables} version 0.6.5.9011. Please use col_footnotes instead." + lifecycle::deprecate_warn( + when = "0.6.6", + what = "col_fnotes_here()", + with = "col_footnotes()" ) col_footnotes(obj) }) @@ -3016,10 +3016,10 @@ setGeneric("col_fnotes_here<-", function(obj, value) standardGeneric("col_fnotes #' @export #' @rdname int_methods setMethod("col_fnotes_here<-", "ANY", function(obj, value) { - .Deprecated( - new = "col_footnotes<-", - old = "col_fnotes_here<-", - msg = "col_fnotes_here<- was deprecated in {rtables} version 0.6.5.9011. Please use col_footnotes<- instead." + lifecycle::deprecate_warn( + when = "0.6.6", + what = I("col_fnotes_here()<-"), + with = I("col_footnotes()<-") ) col_footnotes(obj) <- value }) diff --git a/R/tt_compatibility.R b/R/tt_compatibility.R index 35e42dab1..85959a126 100644 --- a/R/tt_compatibility.R +++ b/R/tt_compatibility.R @@ -383,9 +383,18 @@ only_first_annot <- function(all_annots) { #' @rdname rbind #' @aliases rbind #' @export -rbindl_rtables <- function(x, gap = 0, check_headers = TRUE) { - if (!check_headers) { - warning("check_headers = FALSE is no longer supported, ignoring.") +rbindl_rtables <- function(x, gap = lifecycle::deprecated(), check_headers = lifecycle::deprecated()) { + if (lifecycle::is_present(gap)) { + lifecycle::deprecate_warn( + when = "0.3.2", + what = "rbindl_rtables(gap)" + ) + } + if (lifecycle::is_present(check_headers)) { + lifecycle::deprecate_warn( + when = "0.3.2", + what = "rbindl_rtables(check_headers)" + ) } firstcols <- col_info(x[[1]]) @@ -507,7 +516,7 @@ rbindl_rtables <- function(x, gap = 0, check_headers = TRUE) { setMethod( "rbind", "VTableNodeInfo", function(..., deparse.level = 1) { - rbindl_rtables(list(...), check_headers = TRUE) + rbindl_rtables(list(...)) } ) @@ -530,7 +539,7 @@ setMethod( setMethod( "rbind2", "VTableNodeInfo", function(x, y) { - rbindl_rtables(list(x, y), check_headers = TRUE) + rbindl_rtables(list(x, y)) } ) @@ -926,7 +935,9 @@ chk_compat_cinfos <- function(tt1, tt2) { } -#' **Deprecated:** Insert `rrow`s at (before) a specific location +#' Insert `rrow`s at (before) a specific location +#' +#' `r lifecycle::badge("deprecated")` #' #' This function is deprecated and will be removed in a future release of `rtables`. Please use #' [insert_row_at_path()] or [label_at_path()] instead. @@ -973,7 +984,11 @@ chk_compat_cinfos <- function(tt1, tt2) { #' @export insert_rrow <- function(tbl, rrow, at = 1, ascontent = FALSE) { - .Deprecated("insert_row_at_path or label_at_path(tab)<-", old = "insert_rrow") + lifecycle::deprecate_warn( + when = "0.4.0", + what = "insert_rrow()", + with = I("insert_row_at_path() or label_at_path()") + ) stopifnot( is(tbl, "VTableTree"), is(rrow, "TableRow"), @@ -985,9 +1000,7 @@ insert_rrow <- function(tbl, rrow, at = 1, } if (at == 1) { - return(rbindl_rtables(list(rrow, tbl), - check_headers = TRUE - )) + return(rbindl_rtables(list(rrow, tbl))) } else if (at == nrow(tbl) + 1) { return(rbind2(tbl, rrow)) } diff --git a/R/tt_dotabulation.R b/R/tt_dotabulation.R index 791b0a9ae..903f12eb4 100644 --- a/R/tt_dotabulation.R +++ b/R/tt_dotabulation.R @@ -1132,7 +1132,7 @@ recursive_applysplit <- function(df, #' #' @inheritParams gen_args #' @inheritParams lyt_args -#' @param col_counts (`numeric` or `NULL`)\cr `r lifecycle::badge("deprecated")` if non-`NULL`, column counts +#' @param col_counts (`numeric` or `NULL`)\cr if non-`NULL`, column counts #' which override those calculated automatically during tabulation. Must specify "counts" for *all* #' resulting columns if non-`NULL`. `NA` elements will be replaced with the automatically calculated counts. #' @param col_total (`integer(1)`)\cr the total observations across all columns. Defaults to `nrow(df)`. diff --git a/man/build_table.Rd b/man/build_table.Rd index 37869f8b0..0ebaef7b9 100644 --- a/man/build_table.Rd +++ b/man/build_table.Rd @@ -23,7 +23,7 @@ build_table( \item{alt_counts_df}{(\code{data.frame} or \code{tibble})\cr alternative full dataset the rtables framework will use \emph{only} when calculating column counts.} -\item{col_counts}{(\code{numeric} or \code{NULL})\cr \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} if non-\code{NULL}, column counts +\item{col_counts}{(\code{numeric} or \code{NULL})\cr if non-\code{NULL}, column counts which override those calculated automatically during tabulation. Must specify "counts" for \emph{all} resulting columns if non-\code{NULL}. \code{NA} elements will be replaced with the automatically calculated counts.} diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 000000000..745ab0c78 --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 000000000..d5c9559ed --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 000000000..b61c57c3f --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg new file mode 100644 index 000000000..5d88fc2c6 --- /dev/null +++ b/man/figures/lifecycle-experimental.svg @@ -0,0 +1,21 @@ + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 000000000..897370ecf --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 000000000..7c1721d05 --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 000000000..9c166ff30 --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 000000000..9bf21e76b --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 000000000..db8d757f7 --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/insert_rrow.Rd b/man/insert_rrow.Rd index 6d8d11908..6a25aa49f 100644 --- a/man/insert_rrow.Rd +++ b/man/insert_rrow.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/tt_compatibility.R \name{insert_rrow} \alias{insert_rrow} -\title{\strong{Deprecated:} Insert \code{rrow}s at (before) a specific location} +\title{Insert \code{rrow}s at (before) a specific location} \usage{ insert_rrow(tbl, rrow, at = 1, ascontent = FALSE) } @@ -19,6 +19,9 @@ insert_rrow(tbl, rrow, at = 1, ascontent = FALSE) A \code{TableTree} of the same specific class as \code{tbl}. } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +} +\details{ This function is deprecated and will be removed in a future release of \code{rtables}. Please use \code{\link[=insert_row_at_path]{insert_row_at_path()}} or \code{\link[=label_at_path]{label_at_path()}} instead. } diff --git a/man/rbind.Rd b/man/rbind.Rd index 60ae7be46..b8c5dcde1 100644 --- a/man/rbind.Rd +++ b/man/rbind.Rd @@ -7,7 +7,11 @@ \alias{rbind2,VTableNodeInfo,ANY-method} \title{Row-bind \code{TableTree} and related objects} \usage{ -rbindl_rtables(x, gap = 0, check_headers = TRUE) +rbindl_rtables( + x, + gap = lifecycle::deprecated(), + check_headers = lifecycle::deprecated() +) \S4method{rbind}{VTableNodeInfo}(..., deparse.level = 1) diff --git a/tests/testthat/test-binding.R b/tests/testthat/test-binding.R index 43c8d252f..67fe271f2 100644 --- a/tests/testthat/test-binding.R +++ b/tests/testthat/test-binding.R @@ -166,9 +166,9 @@ test_that("insert_rrow works", { build_table(ex_adsl) ## column numbers don't match - expect_error(suppressWarnings(insert_rrow(tbl, rrow("Total xx", ""), at = 1))) + expect_error(lifecycle::expect_deprecated(insert_rrow(tbl, rrow("Total xx", ""), at = 1))) ## this is ok cause its a LabelRow not a DataRow - expect_silent(suppressWarnings(insert_rrow(tbl, rrow("Total xx"), at = 1))) + expect_silent(lifecycle::expect_deprecated(insert_rrow(tbl, rrow("Total xx"), at = 1))) }) ## regression test for #340 diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index cbd701c8b..37b4f81cd 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -2,9 +2,9 @@ context("deprecated functionality") test_that("deprecated things are still there and work kinda", { - expect_warning(lyt11 <- split_cols_by(lyt = NULL, "ARM"), "deprecated") + lifecycle::expect_deprecated(lyt11 <- split_cols_by(lyt = NULL, "ARM")) expect_identical(lyt11, basic_table() %>% split_cols_by("ARM")) - expect_warning(lyt22 <- split_rows_by(lyt = NULL, "ARM"), "deprecated") + lifecycle::expect_deprecated(lyt22 <- split_rows_by(lyt = NULL, "ARM")) expect_identical(lyt22, basic_table() %>% split_rows_by("ARM")) }) @@ -14,7 +14,7 @@ test_that("deprecated insert_rrow still currently works", { analyze("Sepal.Length") %>% build_table(iris) - expect_warning(res1 <- insert_rrow(tbl, rrow("Hello World")), "Deprecated") + lifecycle::expect_deprecated(res1 <- insert_rrow(tbl, rrow("Hello World"))) realdf <- make_row_df(tbl) o <- options(warn = -1) mf1 <- matrix_form(res1) From b56b7f38d6c8c2cb76e38d60fafc7cf3c868a574 Mon Sep 17 00:00:00 2001 From: edelarua Date: Mon, 13 May 2024 18:33:38 +0000 Subject: [PATCH 2/3] [skip actions] Bump version to 0.6.7.9002 --- DESCRIPTION | 8 ++++---- NEWS.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 301f88678..04b5dcf41 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rtables Title: Reporting Tables -Version: 0.6.7.9001 -Date: 2024-05-02 +Version: 0.6.7.9002 +Date: 2024-05-13 Authors@R: c( person("Gabriel", "Becker", , "gabembecker@gmail.com", role = "aut", comment = "Original creator of the package"), @@ -29,10 +29,10 @@ URL: https://github.com/insightsengineering/rtables, https://insightsengineering.github.io/rtables/ BugReports: https://github.com/insightsengineering/rtables/issues Depends: - R (>= 2.10), formatters (>= 0.5.6), magrittr (>= 1.5), - methods + methods, + R (>= 2.10) Imports: checkmate (>= 2.1.0), htmltools (>= 0.5.4), diff --git a/NEWS.md b/NEWS.md index 498590b92..d4347a482 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## rtables 0.6.7.9001 +## rtables 0.6.7.9002 ### New Features * Added `top_level_section_div` for `basic_table` to set section dividers for top level rows. * Added `keep_label_rows` to `as_result_df` to have these lines visible. From bdafa9d155ef71c7bc829d17c5ba78ae5a7c8308 Mon Sep 17 00:00:00 2001 From: edelarua Date: Mon, 13 May 2024 18:34:36 +0000 Subject: [PATCH 3/3] [skip ci] Update WORDLIST --- inst/WORDLIST | 5 ----- 1 file changed, 5 deletions(-) diff --git a/inst/WORDLIST b/inst/WORDLIST index 0274737d2..85eef8d0e 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,4 +1,3 @@ -Bové CRAN's Carreras Cheatsheet @@ -22,7 +21,6 @@ RStudio Resync Rua STUDYID -Sabanés Saibah Stoilova Subtable @@ -44,7 +42,6 @@ facetting flextable formatter funder -funs getter getters ing @@ -55,14 +52,12 @@ layouting mandatorily multivariable orderable -params pathing postfix postprocessing pre priori programmatically -quartiles reindexed repo repped