Adds stars next to the estimates, or the p-values, whose p-value falls
below the thresholds, one star per threshold passed, with a footnote
giving the thresholds, and hides the columns the stars stand in for. On a
regression table the default pattern is "{estimate}{stars}" and the
p-value column is hidden; on other tables it is "{p.value}{stars}" and
the p-values stay.
Arguments
- x
(
ltsummary)
A table with ap.valuecolumn.- pattern
(
string)
A glue pattern over the table's columns and{stars}, shown in the first column it names, which also gets the footnote. Default is"{estimate}{stars}"for regression tables and"{p.value}{stars}"otherwise. Other common patterns are"{estimate}{stars} ({conf.low}, {conf.high})"and"{estimate} ({conf.low} to {conf.high}){stars}".- thresholds
(
numeric)
The p-value thresholds, between 0 and 1. Default isc(0.001, 0.01, 0.05).- hide_ci
(
scalar logical)
Whether to hide the confidence interval. Default isTRUE.- hide_p
(
scalar logical)
Whether to hide the p-value. Default isTRUEfor regression tables andFALSEotherwise.- hide_se
(
scalar logical)
Whether to hide the standard error. Default isFALSE, which shows it on a regression table.
See also
modify_column_merge(), which the pattern goes through, and
theme_ltsummary_journal(), whose "qjecon" theme is built on this
function.
Other regression tables:
add_glance_table(),
add_global_p(),
add_n_regression,
add_nevent(),
add_vif(),
combine_terms(),
glance_fun_s3(),
global_pvalue_fun(),
tbl_regression(),
tbl_uvregression()
Examples
tbl <- lm(marker ~ age + grade, trial) |>
tbl_regression(label = list(age = "Age", grade = "Grade"))
# 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_abbreviation("CI = Confidence Interval")
# Example 3 ----------------------------------
# stars on the p-values of a summary table
trial |>
tbl_summary(by = trt, include = c(age, grade), missing = "no") |>
add_p() |>
add_significance_stars()