Skip to content

Commit

Permalink
add daniel's suggestions and use dev gtsummary
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmbarrett committed Feb 3, 2025
1 parent 86a680b commit e6610c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Depends:
Imports:
cli,
ggplot2,
gtsummary (>= 2.0.4.9013),
rlang,
tidyselect,
tidysmd (>= 0.2.0)
Expand All @@ -26,7 +27,6 @@ Suggests:
cardx,
covr,
dplyr,
gtsummary,
survey,
testthat (>= 3.0.0),
vdiffr
Expand All @@ -35,3 +35,5 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Remotes:
ddsjoberg/gtsummary
10 changes: 8 additions & 2 deletions R/add_ess_header.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#' add_ess_header()
#'
#' gtsummary::tbl_svysummary(svy, by = qsmk, include = c(age, sex, smokeyrs)) |>
#' add_ess_header(header = "**{level}** \nN = {n_unweighted}; \nESS = {round(n, 1)}")
add_ess_header <- function(x, header = "**{level}** \nESS = {round(n, 1)}") {
#' add_ess_header(header = "**{level}** \nN = {n_unweighted}; \nESS = {format(n, digits = 1, nsmall = 1)}")
add_ess_header <- function(x, header = "**{level}** \nESS = {format(n, digits = 1, nsmall = 1)}") {
# check inputs ---------------------------------------------------------------
rlang::check_installed(c("cards", "dplyr"))
if (!inherits(x, "tbl_svysummary")) {
Expand Down Expand Up @@ -67,6 +67,12 @@ add_ess_header <- function(x, header = "**{level}** \nESS = {round(n, 1)}") {
x <- gtsummary::modify_header(x, gtsummary::all_stat_cols() ~ header) # replace header
x$cards$add_ess_header <- ard_ess # add ESS ARD to results
x$call_list <- updated_call # update the call list

# add abbreviation -----------------------------------------------------------
if (grepl(pattern = "ESS", x = header, fixed = TRUE)) {
x <- gtsummary::modify_abbreviation(x, "ESS = Effective Sample Size")
}

x
}

Expand Down

0 comments on commit e6610c7

Please sign in to comment.