Skip to contents

summarize_attrition_consort() turns raw counts - the source population and how many were removed at each step (wash-in, age, mortality, transfer, ...) - into the attrition table that generate_consort_attrition() and its exporters (to_mermaid(), to_latex(), to_typst(), to_tikz(), to_markdown()) render. With sites it pools several sites by summing the counts step by step. Nothing here reads patient-level data.

Usage

summarize_attrition_consort(
  initial_n = NULL,
  exclusions = NULL,
  sites = NULL,
  min_cell = NULL,
  initial_label = "Source population"
)

Arguments

initial_n

Source population size (single site).

exclusions

What each step removed: a named numeric vector or list (c(Washout = 120, Age = 40)), a data frame with label and excluded (or remaining) and optional reason, or a list of such lists. A step cannot remove more people than are left.

sites

Named list for pooling. Each element is an attrition data frame, a consort_attrition, or list(initial_n =, exclusions =).

min_cell

Suppress counts from 1 to min_cell - 1 and anything they could be recovered from by subtraction (NULL keeps exact counts; for sites the default is 11).

initial_label

Label of the first step.

Value

A consort_attrition data frame (step_number, step_name, subjects_retained, subjects_dropped, percent_retained, exclusion_reason, and n_sites / suppressed where relevant).

Details

A table suppressed for release (min_cell) has NA where a count is hidden; the exporters write those as <11. Pooled output is suppressed by default (min_cell = 11) because it leaves the site. Release the pooled table or the per-site tables, not both: with a hidden site cell the pooled total minus the other sites would give it back.

Examples

att <- summarize_attrition_consort(1000, c(Washout = 100, `Age < 18` = 50, `Died in hospital` = 30))
att$subjects_retained
#> [1] 1000  900  850  820
cat(to_mermaid(att))
#> flowchart TD
#>     S1["1. Source population<br/>(N = 1,000, 100.0%)"]
#>     S2["2. Washout<br/>(N = 900, 90.0%)"]
#>     S1 --> S2
#>     E2["Excluded: 100"]
#>     S1 -.-> E2
#>     S3["3. Age < 18<br/>(N = 850, 85.0%)"]
#>     S2 --> S3
#>     E3["Excluded: 50"]
#>     S2 -.-> E3
#>     S4["4. Died in hospital<br/>(N = 820, 82.0%)"]
#>     S3 --> S4
#>     E4["Excluded: 30"]
#>     S3 -.-> E4