Summary tables for AE

ae_table_grade(
  df_ae,
  ...,
  df_enrol,
  variant = c("max", "sup", "eq"),
  arm = NULL,
  grade = "AEGR",
  subjid = "SUBJID",
  ae_label = "AE",
  percent = TRUE,
  digits = 2,
  total = TRUE
)

Arguments

df_ae

adverse event dataset, one row per AE, containing subjid, soc, and grade.

...

unused

df_enrol

enrollment dataset, one row per patient, containing subjid (and arm if needed). All patients should be in this dataset.

variant

one or several of c("max", "sup", "eq"). max computes the maximum AE grade per patient, sup computes the number of patients having experienced at least one AE of grade higher or equal to X, and eq computes the number of patients having experienced at least one AE of grade equal to X.

arm

name of the treatment column in df_enrol. Case-insensitive. Can be set to NULL.

grade

name of the AE grade column in df_ae. Case-insensitive.

subjid

name of the patient ID in both df_ae and df_enrol. Case-insensitive.

ae_label

the label of adverse events, usually "AE" or "SAE".

percent

whether to show percentages with counts. Defaults to TRUE. Can also be "only" to not show counts.

digits

significant digits for percentages.

total

whether to add a total column for each arm.

Value

a crosstable

Examples

tm = grstat_example()
attach(tm, warn.conflicts=FALSE)

ae_table_grade(df_ae=ae, df_enrol=enrolres, arm=NULL) %>%
  as_flextable(header_show_n=TRUE)

label

variable

Treatment arm

All patients (N=50)

Patient maximum AE grade

No declared AE

1 (2%)

Grade 1

4 (8%)

Grade 2

11 (22%)

Grade 3

15 (30%)

Grade 4

17 (34%)

Grade 5

2 (4%)

Patient had at least one AE of grade

No declared AE

1 (2%)

Grade ≥ 1

49 (98%)

Grade ≥ 2

45 (90%)

Grade ≥ 3

34 (68%)

Grade ≥ 4

19 (38%)

Grade = 5

2 (4%)

Patient had at least one AE of grade

No declared AE

1 (2%)

Grade 1

35 (70%)

Grade 2

29 (58%)

Grade 3

22 (44%)

Grade 4

17 (34%)

Grade 5

2 (4%)

ae_table_grade(df_ae=ae, df_enrol=enrolres, arm="arm") %>% as_flextable(header_show_n=TRUE)

label

variable

Treatment arm

Total

Control (N=25)

Treatment (N=25)

Patient maximum AE grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade 1

2 (8%)

2 (8%)

4 (8%)

Grade 2

4 (16%)

7 (28%)

11 (22%)

Grade 3

8 (32%)

7 (28%)

15 (30%)

Grade 4

9 (36%)

8 (32%)

17 (34%)

Grade 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one AE of grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade ≥ 1

25 (100%)

24 (96%)

49 (98%)

Grade ≥ 2

23 (92%)

22 (88%)

45 (90%)

Grade ≥ 3

19 (76%)

15 (60%)

34 (68%)

Grade ≥ 4

11 (44%)

8 (32%)

19 (38%)

Grade = 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one AE of grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade 1

18 (72%)

17 (68%)

35 (70%)

Grade 2

16 (64%)

13 (52%)

29 (58%)

Grade 3

13 (52%)

9 (36%)

22 (44%)

Grade 4

9 (36%)

8 (32%)

17 (34%)

Grade 5

2 (8%)

0 (0%)

2 (4%)

#To get SAE only, filter df_ae first ae %>% dplyr::filter(sae=="Yes") %>% ae_table_grade(df_enrol=enrolres, arm="arm", ae_label="SAE") %>% as_flextable(header_show_n=TRUE)

label

variable

Treatment arm

Total

Control (N=25)

Treatment (N=25)

Patient maximum SAE grade

No declared SAE

17 (68%)

20 (80%)

37 (74%)

Grade 1

1 (4%)

0 (0%)

1 (2%)

Grade 2

0 (0%)

1 (4%)

1 (2%)

Grade 3

4 (16%)

3 (12%)

7 (14%)

Grade 4

1 (4%)

1 (4%)

2 (4%)

Grade 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one SAE of grade

No declared SAE

17 (68%)

20 (80%)

37 (74%)

Grade ≥ 1

8 (32%)

5 (20%)

13 (26%)

Grade ≥ 2

7 (28%)

5 (20%)

12 (24%)

Grade ≥ 3

7 (28%)

4 (16%)

11 (22%)

Grade ≥ 4

3 (12%)

1 (4%)

4 (8%)

Grade = 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one SAE of grade

No declared SAE

17 (68%)

20 (80%)

37 (74%)

Grade 1

2 (8%)

0 (0%)

2 (4%)

Grade 2

1 (4%)

1 (4%)

2 (4%)

Grade 3

4 (16%)

4 (16%)

8 (16%)

Grade 4

1 (4%)

1 (4%)

2 (4%)

Grade 5

2 (8%)

0 (0%)

2 (4%)

#To describe a sub-population, filter df_enrol first enrolres2 = enrolres %>% dplyr::filter(arm=="Control") ae %>% ae_table_grade(df_enrol=enrolres2, arm="arm") %>% as_flextable(header_show_n=TRUE)

label

variable

Treatment arm

Total

Control (N=25)

Patient maximum AE grade

Grade 1

2 (8%)

2 (8%)

Grade 2

4 (16%)

4 (16%)

Grade 3

8 (32%)

8 (32%)

Grade 4

9 (36%)

9 (36%)

Grade 5

2 (8%)

2 (8%)

Patient had at least one AE of grade

Grade ≥ 1

25 (100%)

25 (100%)

Grade ≥ 2

23 (92%)

23 (92%)

Grade ≥ 3

19 (76%)

19 (76%)

Grade ≥ 4

11 (44%)

11 (44%)

Grade = 5

2 (8%)

2 (8%)

Patient had at least one AE of grade

Grade 1

18 (72%)

18 (72%)

Grade 2

16 (64%)

16 (64%)

Grade 3

13 (52%)

13 (52%)

Grade 4

9 (36%)

9 (36%)

Grade 5

2 (8%)

2 (8%)

#You can also filter the AE table ae %>% ae_table_grade(df_enrol=enrolres, arm="arm") %>% dplyr::filter(!variable %in% c("Grade 1", "Grade 2")) %>% as_flextable(header_show_n=TRUE)

label

variable

Treatment arm

Total

Control (N=25)

Treatment (N=25)

Patient maximum AE grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade 3

8 (32%)

7 (28%)

15 (30%)

Grade 4

9 (36%)

8 (32%)

17 (34%)

Grade 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one AE of grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade ≥ 1

25 (100%)

24 (96%)

49 (98%)

Grade ≥ 2

23 (92%)

22 (88%)

45 (90%)

Grade ≥ 3

19 (76%)

15 (60%)

34 (68%)

Grade ≥ 4

11 (44%)

8 (32%)

19 (38%)

Grade = 5

2 (8%)

0 (0%)

2 (4%)

Patient had at least one AE of grade

No declared AE

0 (0%)

1 (4%)

1 (2%)

Grade 3

13 (52%)

9 (36%)

22 (44%)

Grade 4

9 (36%)

8 (32%)

17 (34%)

Grade 5

2 (8%)

0 (0%)

2 (4%)