-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'show_header_name_update' of https://github.com/ddsjober…
…g/gtsummary into show_header_name_update
- Loading branch information
Showing
2 changed files
with
84 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
) | ||
}) |