From 92ca979ebb7f09a09ec2d087b6c8075455c2b86d Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Mon, 9 Dec 2024 20:18:05 -0800 Subject: [PATCH] abbreviation updates --- R/as_kable_extra.R | 9 ++++++--- R/modify_source_note.R | 5 +++++ man/modify_abbreviation.Rd | 2 ++ man/modify_source_note.Rd | 6 ++++++ man/tbl_continuous.Rd | 2 ++ man/tbl_regression.Rd | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/R/as_kable_extra.R b/R/as_kable_extra.R index ea43c539b..19dfe55e1 100644 --- a/R/as_kable_extra.R +++ b/R/as_kable_extra.R @@ -353,7 +353,11 @@ table_styling_to_kable_extra_calls <- function(x, escape, format, addtl_fmt, ... seq_len(nrow(x$table_styling$source_note)), \(i) { expr( - kableExtra::footnote(number = !!x$table_styling$source_note$source_note[i], escape = !!escape) + kableExtra::footnote( + general = !!x$table_styling$source_note$source_note[i], + escape = !!escape, + general_title = "" + ) ) } ) @@ -371,8 +375,7 @@ table_styling_to_kable_extra_calls <- function(x, escape, format, addtl_fmt, ... ": ", . )), escape = !!escape, - general_title = "", - footnote_order = c("number", "alphabet", "symbol", "general") + general_title = "" ) ), .default = list() diff --git a/R/modify_source_note.R b/R/modify_source_note.R index 05ed03c26..a48211ffb 100644 --- a/R/modify_source_note.R +++ b/R/modify_source_note.R @@ -22,7 +22,12 @@ #' @name modify_source_note #' #' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") || identical(Sys.getenv("IN_PKGDOWN"), "true") +#' # Example 1 ---------------------------------- +#' tbl <- tbl_summary(trial, include = c(marker, grade), missing = "no") |> +#' modify_source_note("Results as of June 26, 2015") #' +#' # Example 2 ---------------------------------- +#' remove_source_note(tbl, source_note_id = 1) NULL #' @export diff --git a/man/modify_abbreviation.Rd b/man/modify_abbreviation.Rd index 8a857d867..f0959b145 100644 --- a/man/modify_abbreviation.Rd +++ b/man/modify_abbreviation.Rd @@ -29,6 +29,7 @@ All abbreviations will be coalesced when printing the final table into a single source note. } \examples{ +\dontshow{if ((identical(Sys.getenv("NOT_CRAN"), "true") || identical(Sys.getenv("IN_PKGDOWN"), "true")) && gtsummary:::is_pkg_installed(c("cardx", "broom", "broom.helpers"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Example 1 ---------------------------------- tbl_summary( trial, @@ -43,4 +44,5 @@ tbl_summary( lm(marker ~ trt, trial) |> tbl_regression() |> remove_abbreviation("CI = Confidence Interval") +\dontshow{\}) # examplesIf} } diff --git a/man/modify_source_note.Rd b/man/modify_source_note.Rd index 00757805b..e771a01cf 100644 --- a/man/modify_source_note.Rd +++ b/man/modify_source_note.Rd @@ -38,5 +38,11 @@ Source notes are not supported by \code{as_kable_extra()}. } \examples{ \dontshow{if (identical(Sys.getenv("NOT_CRAN"), "true") || identical(Sys.getenv("IN_PKGDOWN"), "true")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# Example 1 ---------------------------------- +tbl <- tbl_summary(trial, include = c(marker, grade), missing = "no") |> + modify_source_note("Results as of June 26, 2015") + +# Example 2 ---------------------------------- +remove_source_note(tbl, source_note_id = 1) \dontshow{\}) # examplesIf} } diff --git a/man/tbl_continuous.Rd b/man/tbl_continuous.Rd index 2b8bcca28..c35703ad4 100644 --- a/man/tbl_continuous.Rd +++ b/man/tbl_continuous.Rd @@ -54,6 +54,7 @@ a gtsummary table Summarize a continuous variable by one or more categorical variables } \examples{ +\dontshow{if (identical(Sys.getenv("NOT_CRAN"), "true") || identical(Sys.getenv("IN_PKGDOWN"), "true")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Example 1 ---------------------------------- tbl_continuous( data = trial, @@ -73,4 +74,5 @@ trial |> value = all_subjects ~ 1, label = list(all_subjects = "All Subjects") ) +\dontshow{\}) # examplesIf} } diff --git a/man/tbl_regression.Rd b/man/tbl_regression.Rd index 2529d4076..6bd43aa62 100644 --- a/man/tbl_regression.Rd +++ b/man/tbl_regression.Rd @@ -103,7 +103,7 @@ to print the random components. } \examples{ -\dontshow{if (gtsummary:::is_pkg_installed(c("cardx", "broom", "broom.helpers"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if ((identical(Sys.getenv("NOT_CRAN"), "true") || identical(Sys.getenv("IN_PKGDOWN"), "true")) && gtsummary:::is_pkg_installed(c("cardx", "broom", "broom.helpers"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Example 1 ---------------------------------- glm(response ~ age + grade, trial, family = binomial()) |> tbl_regression(exponentiate = TRUE)