Learn R Programming

dtlg (version 0.0.2)

multi_event_true: Summarise multiple AESI-like events per treatment arm

Description

multi_event_true() generates a summary table showing the number and percentage of patients with at least one event across multiple binary indicator variables (e.g., flags for adverse events of special interest).

Usage

multi_event_true(
  dt,
  event_vars,
  patient,
  treat,
  heading,
  label = NULL,
  .total_dt = NULL,
  indent = nbsp(n = 4L),
  pct_dec = 1
)

Value

A one-element list containing a data.table with one row per event plus one header row. The first column is "stats" (row labels), and subsequent columns are one per treatment arm, with values in "n (x%)"

format.

Arguments

dt

A data.frame or data.table containing the binary event flags and subject-level data.

event_vars

A character vector of column names (binary flags) to summarise.

patient

A string giving the name of the variable that uniquely identifies each patient (e.g., "USUBJID").

treat

A string giving the name of the treatment variable (e.g., "ARM").

heading

A string to be shown as the first row in the output, usually a summary descriptor such as "Total number of patients with at least one".

label

Optional. A character vector of the same length as event_vars giving human-readable labels for the output table rows. If NULL, labels are extracted from the label attribute of each variable, or fall back to the variable name.

.total_dt

A data.frame or data.table containing the total analysis population (denominator). If NULL, dt is used as the denominator.

indent

A string to indent the row labels (e.g., " " or nbsp(n = 4L) for non-breaking spaces).

pct_dec

An integer indicating how many decimal places to show in percentages (default is 1).

Details

Each event is counted only once per patient. This function is typically used for summarising Adverse Events of Special Interest (AESIs) or other derived flags (e.g., SER, FATAL, RELDSM) that are binary (TRUE/FALSE).

See Also

event_count(), total_events()

Examples

Run this code
aesi_vars <- c(
  "FATAL", "SER", "SERWD", "SERDSM", "RELSER",
  "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV"
)

heading <- "Total number of patients with at least one AE"

multi_event_true(
  dt = aesi,
  event_vars = aesi_vars,
  patient = "USUBJID",
  treat = "ARM",
  heading = heading,
  .total_dt = adsl,
  indent = "  "
)[[1]]

Run the code above in your browser using DataLab