View source: R/add_significance_stars.R
add_significance_stars | R Documentation |
Add significance stars to estimates with small p-values
add_significance_stars(
x,
pattern = ifelse(inherits(x, c("tbl_regression", "tbl_uvregression")),
"{estimate}{stars}", "{p.value}{stars}"),
thresholds = c(0.001, 0.01, 0.05),
hide_ci = TRUE,
hide_p = inherits(x, c("tbl_regression", "tbl_uvregression")),
hide_se = FALSE
)
x |
( |
pattern |
( |
thresholds |
( |
hide_ci |
(scalar |
hide_p |
(scalar |
hide_se |
(scalar |
a 'gtsummary' table
tbl <-
lm(time ~ ph.ecog + sex, survival::lung) |>
tbl_regression(label = list(ph.ecog = "ECOG Score", sex = "Sex"))
# Example 1 ----------------------------------
tbl |>
add_significance_stars(hide_ci = FALSE, hide_p = FALSE)
# Example 2 ----------------------------------
tbl |>
add_significance_stars(
pattern = "{estimate} ({conf.low}, {conf.high}){stars}",
hide_ci = TRUE, hide_se = TRUE
) |>
modify_header(estimate = "**Beta (95% CI)**") |>
modify_footnote(estimate = "CI = Confidence Interval", abbreviation = TRUE)
# Example 3 ----------------------------------
# Use ' \n' to put a line break between beta and SE
tbl |>
add_significance_stars(
hide_se = TRUE,
pattern = "{estimate}{stars} \n({std.error})"
) |>
modify_header(estimate = "**Beta \n(SE)**") |>
modify_footnote(estimate = "SE = Standard Error", abbreviation = TRUE) |>
as_gt() |>
gt::fmt_markdown(columns = everything()) |>
gt::tab_style(
style = "vertical-align:top",
locations = gt::cells_body(columns = label)
)
# Example 4 ----------------------------------
lm(marker ~ stage + grade, data = trial) |>
tbl_regression() |>
add_global_p() |>
add_significance_stars(
hide_p = FALSE,
pattern = "{p.value}{stars}"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.