From b803ee3563fbbb1130d7579b589e49a4579781e1 Mon Sep 17 00:00:00 2001 From: gravesti Date: Wed, 16 Aug 2023 11:15:46 +0200 Subject: [PATCH 1/2] add simple footnote text function --- NAMESPACE | 1 + R/matching.R | 16 ++++++++++++++++ man/ess_footnote_text.Rd | 20 ++++++++++++++++++++ tests/testthat/test-matching.R | 9 +++++++++ 4 files changed, 46 insertions(+) create mode 100644 man/ess_footnote_text.Rd create mode 100644 tests/testthat/test-matching.R diff --git a/NAMESPACE b/NAMESPACE index 23412536..d86faf23 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(bucher) export(center_ipd) export(check_weights) export(dummize_ipd) +export(ess_footnote_text) export(estimate_weights) export(generate_survival_data) export(log_cum_haz_plot) diff --git a/R/matching.R b/R/matching.R index aeb64447..285f49d7 100644 --- a/R/matching.R +++ b/R/matching.R @@ -312,3 +312,19 @@ print.maicplus_check_weights <- function(x, mean_digits = 2, prop_digits = 2, sd } } } + +#' Prints Note on Expected Sample Size Reduction +#' +#' @param width Number of characters to break string into new lines (`\n`). +#' +#' @return A character string +#' @export +#' +#' @examples +#' ess_footnote_text(width = 80) +ess_footnote_text <- function(width = 0.9 * getOption("width")) { + text <- "An ESS reduction up to ~60% is not unexpected based on the 2021 survey of NICE's technology appraisals +(https://onlinelibrary.wiley.com/doi/full/10.1002/jrsm.1511), whereas a reduction of >75% is less common +and it may be considered sub optimal." + paste0(strwrap(text, width = width), collapse = "\n") +} diff --git a/man/ess_footnote_text.Rd b/man/ess_footnote_text.Rd new file mode 100644 index 00000000..b5afe80d --- /dev/null +++ b/man/ess_footnote_text.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/matching.R +\name{ess_footnote_text} +\alias{ess_footnote_text} +\title{Prints Note on Expected Sample Size Reduction} +\usage{ +ess_footnote_text(width = 0.9 * getOption("width")) +} +\arguments{ +\item{width}{Number of characters to break string into new lines (\verb{\\n}).} +} +\value{ +A character string +} +\description{ +Prints Note on Expected Sample Size Reduction +} +\examples{ +ess_footnote_text(width = 80) +} diff --git a/tests/testthat/test-matching.R b/tests/testthat/test-matching.R new file mode 100644 index 00000000..6a2de49b --- /dev/null +++ b/tests/testthat/test-matching.R @@ -0,0 +1,9 @@ +test_that("ess_footnote_text works", { + expect_equal( + ess_footnote_text(width = 100), + paste0( + "An ESS reduction up to ~60% is not unexpected based on the 2021 survey of NICE's technology\n", + "appraisals (https://onlinelibrary.wiley.com/doi/full/10.1002/jrsm.1511), whereas a reduction of\n", + ">75% is less common and it may be considered sub optimal." + )) +}) From 4adb9b8584061e9e5f6ebdc667e2558f1ce354f7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 09:19:04 +0000 Subject: [PATCH 2/2] [skip actions] Restyle files --- tests/testthat/test-matching.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-matching.R b/tests/testthat/test-matching.R index 6a2de49b..6f42e0f3 100644 --- a/tests/testthat/test-matching.R +++ b/tests/testthat/test-matching.R @@ -5,5 +5,6 @@ test_that("ess_footnote_text works", { "An ESS reduction up to ~60% is not unexpected based on the 2021 survey of NICE's technology\n", "appraisals (https://onlinelibrary.wiley.com/doi/full/10.1002/jrsm.1511), whereas a reduction of\n", ">75% is less common and it may be considered sub optimal." - )) + ) + ) })