Skip to content

Commit

Permalink
Merge branch 'show_header_name_update' of https://github.com/ddsjober…
Browse files Browse the repository at this point in the history
…g/gtsummary into show_header_name_update
  • Loading branch information
ddsjoberg committed Sep 4, 2024
2 parents 34c2591 + 02e4546 commit 596fb4d
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 19 deletions.
66 changes: 50 additions & 16 deletions tests/testthat/_snaps/show_header_names.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
# show_header_names() works
# show_header_names() works with tbl_summary()

Code
show_header_names(tbl_summary(trial, include = age, by = trt, missing = "no"))
Output
Column Name Header level* N* n* p*
label "**Characteristic**" 200
stat_1 "**Drug A** \nN = 98" Drug A 200 98 0.490
stat_2 "**Drug B** \nN = 102" Drug B 200 102 0.510
Message
i As a usage guide, the code below re-creates the current column headers.
modify_header(
label = '**Characteristic**',
stat_1 = '**Drug A**
N = 98',
stat_2 = '**Drug B**
N = 102'
)
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

# show_header_names() works with tbl_regression

Code
show_header_names(tbl_regression(mod_logistic))
Output
Column Name Header N* N_event*
label "**Characteristic**" 183 58.0
estimate "**log(OR)**" 183 58.0
conf.low "**95% CI**" 183 58.0
p.value "**p-value**" 183 58.0
Message
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

# show_header_names() works with tbl_uvregression

Code
show_header_names(tbl_uvregression(trial, x = trt, include = c(marker, age),
show_single_row = trt, method = lm))
Output
Column Name Header
label "**Outcome**"
stat_n "**N**"
estimate "**Beta**"
conf.low "**95% CI**"
p.value "**p-value**"
Column Name Column Header
------------ --------------------
label **Characteristic**
stat_1 **Drug A**
N = 98
stat_2 **Drug B**
N = 102
Message
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

# show_header_names() works with tbl_survfit

Code
show_header_names(tbl_survfit(trial, include = trt, y = "Surv(ttdeath, death)",
probs = 0.5))
Output
Column Name Header prob*
label "**Characteristic**"
stat_1 "**50% Percentile**" 0.500
Message
* These values may be dynamically placed into headers (and other locations).
i Review the `modify_header()` (`?gtsummary::modify()`) help for examples.

37 changes: 34 additions & 3 deletions tests/testthat/test-show_header_names.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
skip_on_os("windows")

test_that("show_header_names() works", {
test_that("show_header_names() works with tbl_summary()", {
expect_snapshot(
tbl_summary(trial, include = age, by = trt, missing = "no") |>
show_header_names()
)
})

test_that("show_header_names() works with tbl_regression", {
mod_logistic <- glm(response ~ age + stage, trial, family = binomial)
expect_snapshot(
tbl_regression(mod_logistic) |>
show_header_names()
)
})

test_that("show_header_names() works with tbl_uvregression", {
expect_snapshot(
tbl_uvregression(
trial,
x = trt,
include = c(marker, age),
show_single_row = trt,
method = lm
)|>
show_header_names()
)
})

test_that("show_header_names() works with tbl_survfit", {
expect_snapshot(
trial |>
tbl_survfit(
include = trt,
y = "Surv(ttdeath, death)",
probs = 0.5
)|>
show_header_names()
)
})

0 comments on commit 596fb4d

Please sign in to comment.