# ratio_summary: Summarize the ratio of two variables In gtsummary: Presentation-Ready Data Summary and Analytic Result Tables

## Description

\lifecycle

experimental This helper, to be used with `tbl_custom_summary()`, creates a function computing the ratio of two continuous variables and its confidence interval.

## Usage

 `1` ```ratio_summary(numerator, denominator, na.rm = TRUE, conf.level = 0.95) ```

## Arguments

 `numerator` String indicating the name of the variable to be summed for computing the numerator. `denominator` String indicating the name of the variable to be summed for computing the denominator. `na.rm` Should missing values be removed before summing the numerator and the denominator? (default is `TRUE`) `conf.level` Confidence level for the returned confidence interval. Must be strictly greater than 0 and less than 1. Default to 0.95, which corresponds to a 95 percent confidence interval.

## Details

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.

Example 1

## Author(s)

Joseph Larmarange

Other tbl_custom_summary tools: `add_overall()`, `continuous_summary()`, `proportion_summary()`, `tbl_custom_summary()`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```# Example 1 ---------------------------------- ratio_summary_ex1 <- 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(3, 2, 2, 0, 0), overall_row = TRUE, overall_row_label = "All stages & grades" ) %>% bold_labels() %>% modify_footnote( update = all_stat_cols() ~ "Ratio [95% CI] (n/N)" ) ```

gtsummary documentation built on Jan. 21, 2022, 1:09 a.m.