forked from ddsjoberg/gtsummary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated
show_header_names()
output format (ddsjoberg#1953)
* add unit tests for new `show_header_names()` output * add_difference.tbl_summary() snaps * updating `show_header_names() * Update modify.R * updates --------- Co-authored-by: ayogasekaram <[email protected]>
- Loading branch information
1 parent
7e2245d
commit 422eaee
Showing
6 changed files
with
134 additions
and
51 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,6 +1,6 @@ | ||
Package: gtsummary | ||
Title: Presentation-Ready Data Summary and Analytic Result Tables | ||
Version: 2.0.1.9012 | ||
Version: 2.0.1.9013 | ||
Authors@R: c( | ||
person("Daniel D.", "Sjoberg", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-0862-2018")), | ||
|
@@ -45,7 +45,7 @@ BugReports: https://github.com/ddsjoberg/gtsummary/issues | |
Depends: | ||
R (>= 4.2) | ||
Imports: | ||
cards (>= 0.2.1.9017), | ||
cards (>= 0.2.2), | ||
cli (>= 3.6.1), | ||
dplyr (>= 1.1.3), | ||
glue (>= 1.6.2), | ||
|
@@ -60,7 +60,7 @@ Suggests: | |
broom.helpers (>= 1.17.0), | ||
broom.mixed (>= 0.2.9), | ||
car (>= 3.0-11), | ||
cardx (>= 0.2.0.9008), | ||
cardx (>= 0.2.1), | ||
cmprsk, | ||
effectsize (>= 0.6.0), | ||
emmeans (>= 1.7.3), | ||
|
@@ -85,7 +85,6 @@ Suggests: | |
testthat (>= 3.2.0), | ||
withr (>= 2.5.0), | ||
workflows (>= 0.2.4) | ||
Remotes: insightsengineering/cards, insightsengineering/cardx | ||
VignetteBuilder: | ||
knitr | ||
RdMacros: | ||
|
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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() | ||
) | ||
}) |