Skip to contents

[Stable]
This function creates summary tables of adverse events (AEs) by grade, for each treatment arm if provided. By default, it shows three measures:

  • "max": highest AE grade experienced by each patient

  • "sup": at least one AE of grade ≥ x

  • "eq": at least one AE of grade == x

Converts an object of class ae_table_grade to a formatted flextable.

Usage

ae_table_grade(
  data_ae,
  ...,
  data_pat,
  measure = c("max", "sup", "eq"),
  arm = NULL,
  grade = "AEGR",
  subjid = "SUBJID",
  ae_label = "AE",
  percent_pattern = "{n} ({p}%)",
  percent_digits = 0,
  zero_value = "0",
  total = TRUE,
  na_strategy = list(display = "always", grouped = TRUE)
)

# S3 method for class 'ae_table_grade'
as_flextable(x, ..., padding_v = NULL)

Arguments

data_ae

Data frame of adverse events, with one row per AE.

...

Unused.

data_pat

Data frame of enrolled patients, with one row per patient.

measure

Character vector specifying which variants to compute: "max", "sup", "eq".

arm

Name of the arm column in data_pat. If NULL, all patients are pooled.

grade

Name of the AE grade column in data_ae.

subjid

Name of the subject ID column (in both data frames).

ae_label

Label used in the output tables (e.g. "AE", "Toxicity").

percent_pattern

Pattern used to format counts and percentages. Use {n} and {p} as placeholders.

percent_digits

Number of digits to show for percentages.

zero_value

String to use when count is zero.

total

Logical. If TRUE, adds a "Total" column across arms (only if multiple arms exist).

na_strategy

A named list controlling how missing AEs or absent patients are displayed in the output tables. Must contain display (one of "if_any" or "always") and grouped (logical).

x

An object of class ae_table_grade.

padding_v

Vertical padding for cells.

Value

A data frame of class ae_table_grade, ready for use with as_flextable().

A flextable object ready to print or export.

Examples

db = grstat_example(N=200, p_na=0.1)
ae_table_grade(db$ae, data_pat=db$enrolres,
               total=FALSE, percent_digits=1) %>%
  as_flextable()

Measure

Level

All patients
(N=200)

Patients by maximum AE grade

Grade 1

41 (20.5%)

Grade 2

64 (32.0%)

Grade 3

50 (25.0%)

Grade 4

31 (15.5%)

Grade 5

3 (1.5%)

Patients with at least one AE at or above each grade

Grade ≥ 1

189 (94.5%)

Grade ≥ 2

148 (74.0%)

Grade ≥ 3

84 (42.0%)

Grade ≥ 4

34 (17.0%)

Grade = 5

3 (1.5%)

Patients with at least one AE at each grade

Grade 1

156 (78.0%)

Grade 2

103 (51.5%)

Grade 3

56 (28.0%)

Grade 4

33 (16.5%)

Grade 5

3 (1.5%)

AE grade completeness

No AE reported

8 (4.0%)

All grades missing

3 (1.5%)

Some grades missing

59 (29.5%)

db = grstat_example(N=20, p_na=0) ae_table_grade(db$ae, data_pat=db$enrolres, arm="ARM", measure=c("max", "sup"), total=TRUE, zero_value="-", na_strategy=list(display="always", grouped=TRUE)) %>% as_flextable()

Measure

Level

Treatment arm

Total

Control
(N=10)

Treatment
(N=10)

Patients by maximum AE grade

Grade 1

4 (40%)

4 (40%)

8 (40%)

Grade 2

2 (20%)

1 (10%)

3 (15%)

Grade 3

3 (30%)

-

3 (15%)

Grade 4

1 (10%)

4 (40%)

5 (25%)

Grade 5

-

1 (10%)

1 (5%)

Patients with at least one AE at or above each grade

Grade ≥ 1

10 (100%)

10 (100%)

20 (100%)

Grade ≥ 2

6 (60%)

6 (60%)

12 (60%)

Grade ≥ 3

4 (40%)

5 (50%)

9 (45%)

Grade ≥ 4

1 (10%)

5 (50%)

6 (30%)

Grade = 5

-

1 (10%)

1 (5%)

AE grade completeness

No AE reported

-

-

-

All grades missing

-

-

-

Some grades missing

-

-

-