View source: R/utils-tbl_custom_summary.R
ratio_summary | R Documentation |
experimental
This helper, to be used with tbl_custom_summary()
, creates a function
computing the ratio of two continuous variables and its confidence interval.
ratio_summary(numerator, denominator, na.rm = TRUE, conf.level = 0.95)
numerator |
( |
denominator |
( |
na.rm |
(scalar |
conf.level |
(scalar |
Computed statistics:
{num}
sum of the variable defined by numerator
{denom}
sum of the variable defined by denominator
{ratio}
ratio of num
by denom
{conf.low}
lower confidence interval
{conf.high}
upper confidence interval
Confidence interval is computed with stats::poisson.test()
, if and only if
num
is an integer.
Joseph Larmarange
# Example 1 ----------------------------------
trial |>
tbl_custom_summary(
include = c("stage", "grade"),
by = "trt",
stat_fns = ~ ratio_summary("response", "ttdeath"),
statistic = ~"{ratio} [{conf.low}; {conf.high}] ({num}/{denom})",
digits = ~ c(ratio = 3, conf.low = 2, conf.high = 2),
overall_row = TRUE,
overall_row_label = "All stages & grades"
) |>
bold_labels() |>
modify_footnote(all_stat_cols() ~ "Ratio [95% CI] (n/N)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.