Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate footnotes and removing wrap_text #826

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,3 @@ Collate:
'utils_factor.R'
'utils_grid.R'
'utils_rtables.R'
'wrap_text.R'
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
function to speed up data set loading in tests/examples.
* Updated all tests to use `rcd_2022_06_27` version of cached data.
* Added more tests to increase code coverage.
* Deprecated badge and warning for `wrap_txt` and its file.
* Added legend to `g_step`.
* Added formatting functions `format_fraction_fixed_dp` and
`format_count_fraction_fixed_dp` with fixed single decimal place in percentages.
Expand Down Expand Up @@ -51,6 +50,8 @@
* Created separate `.R` files for logistic regression and cox regression helper functions.
* Removed all template tests from `tern`. These tests are in internal repo `scda.test`.
* Replaced deprecated function `forcats::fct_explicit_na` with `forcats::fct_na_value_to_level`.
* Removal of deprecated `wrap_text` and related files.
* Deprecation cycle started for `footnotes` functions.

# tern 0.7.10

Expand Down
13 changes: 9 additions & 4 deletions R/footnotes.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Assign Footnotes
#'
#' @description `r lifecycle::badge("stable")`
#' @description `r lifecycle::badge("deprecated")`
#'
#' Assign value to attribute footnote of object `x`.
#'
Expand All @@ -12,14 +12,15 @@
#' footnotes(x) <- "Species are equally distributed"
#' attributes(x)
`footnotes<-` <- function(x, value = NULL) { # nolint
dep_msg <- 'Please use current implementation in rtables or directly attr(x, "footnote")'
lifecycle::deprecate_warn("0.7.11", "footnotes()", details = dep_msg)
attr(x, "footnote") <- value
x
}


#' Retrieve Footnotes
#'
#' @description `r lifecycle::badge("stable")`
#' @description `r lifecycle::badge("deprecated")`
#'
#' Retrieve value from attribute `footnote` of object `x`.
#'
Expand All @@ -30,12 +31,14 @@
#' footnotes(x) <- "Species are equally distributed"
#' footnotes(x)
footnotes <- function(x) {
dep_msg <- 'Please use current implementation in rtables or directly attr(x, "footnote")'
lifecycle::deprecate_warn("0.7.11", "footnotes()", details = dep_msg)
attr(x, "footnote")
}

#' Add Footnotes
#'
#' @description `r lifecycle::badge("stable")`
#' @description `r lifecycle::badge("deprecated")`
#'
#' This adds more footnotes.
#'
Expand All @@ -49,6 +52,8 @@ footnotes <- function(x) {
#' add_footnotes(x) <- "Add more footnotes"
#' footnotes(x)
`add_footnotes<-` <- function(x, value) { # nolint
dep_msg <- 'Please use current implementation in rtables or directly attr(x, "footnote")'
lifecycle::deprecate_warn("0.7.11", "add_footnotes()", details = dep_msg)
footnotes(x) <- c(footnotes(x), value)
x
}
6 changes: 0 additions & 6 deletions R/g_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,6 @@ g_forest <- function(tbl, # nolint
vp = grid::plotViewport(margins = rep(1, 4))
)

fn <- footnotes(tbl)
if (!is.null(fn)) {
footnotes(grob_forest) <- fn
message("grob footnote is not added to plot; suggest to use decorate_grob() to further decorate the grob")
}

Melkiades marked this conversation as resolved.
Show resolved Hide resolved
if (draw) {
if (newpage) grid::grid.newpage()
grid::grid.draw(grob_forest)
Expand Down
110 changes: 0 additions & 110 deletions R/wrap_text.R

This file was deleted.

2 changes: 1 addition & 1 deletion man/add_footnotes-set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/footnotes-set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/footnotes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions tests/testthat/_snaps/wrap_text.md

This file was deleted.

4 changes: 2 additions & 2 deletions tests/testthat/test-footnotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ testthat::test_that("footnotes works correctly", {
x <- table(iris$Species)
footnotes(x) <- "Species are equally distributed"

res <- testthat::expect_silent(footnotes(x))
res <- footnotes(x)
testthat::expect_snapshot(res)
})

Expand All @@ -11,6 +11,6 @@ testthat::test_that("add_footnotes works correctly", {
footnotes(x) <- "Species are equally distributed"
add_footnotes(x) <- "Add more footnotes"

res <- testthat::expect_silent(footnotes(x))
res <- footnotes(x)
testthat::expect_snapshot(res)
})
8 changes: 0 additions & 8 deletions tests/testthat/test-wrap_text.R

This file was deleted.