Learn R Programming

dtlg (version 0.0.2)

event_count_by: Summarise adverse events by arm and other grouping variables

Description

event_count_by() creates a tabular summary of adverse events grouped by a higher-level classification variable (e.g., system organ class), and counts both the number of events and the number of unique patients per treatment arm.

Usage

event_count_by(
  dt,
  patient,
  treat,
  rows_by,
  target,
  .total_dt = dt,
  indent = nbsp(n = 4L),
  pct_dec = 1
)

Value

A data.table with the following structure:

  • One row per combination of rows_by and target

  • One row per group total (Total number of events)

  • One row per patient-level total (Total number of patients with at least one event)

Columns include:

  • stats: character column with labels

  • one column per level of the treat variable, formatted as "n (x%)"

Arguments

dt

A data.frame or data.table containing the adverse event data and patient-level identifiers.

patient

A string giving the name of the patient identifier variable (e.g., "USUBJID").

treat

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

rows_by

A string giving the name of the grouping variable (e.g., "AEBODSYS" for body system).

target

A string giving the name of the variable to report within each group (e.g., "AEDECOD" for preferred term).

.total_dt

A data.frame or data.table containing the denominator population. Defaults to dt.

indent

A string used to indent row labels (e.g., " " or nbsp(n = 4L)).

pct_dec

Integer. Number of decimal places to show in percentages. Defaults to 1.

See Also

event_count(), calc_stats(), total_events()

Examples

Run this code
event_count_by(
  dt = adae[adae$ANL01FL == "Y"],
  patient = 'USUBJID',
  treat = 'ARM',
  rows_by = 'AEBODSYS',
  target = 'AEDECOD',
  .total_dt = adsl,
  indent = ' '
)

Run the code above in your browser using DataLab