The function ae_table_grade()
creates a summary table of maximum AE grades for each patient according to the CTCAE grade.
The resulting dataframe can be piped to as_flextable()
to get a nicely formatted flextable.
Usage
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, andeq
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 toNULL
.- grade
name of the AE grade column in
df_ae
. Case-insensitive.- subjid
name of the patient ID in both
df_ae
anddf_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.
See also
ae_table_grade()
, ae_table_soc()
, ae_plot_grade()
, ae_plot_grade_sum()
, butterfly_plot()
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=200)
Patient maximum AE grade
No declared AE
3 (2%)
Grade 1
35 (18%)
Grade 2
62 (31%)
Grade 3
51 (26%)
Grade 4
39 (20%)
Grade 5
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (2%)
Grade ≥ 1
197 (98%)
Grade ≥ 2
162 (81%)
Grade ≥ 3
100 (50%)
Grade ≥ 4
49 (24%)
Grade = 5
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (2%)
Grade 1
164 (82%)
Grade 2
117 (58%)
Grade 3
62 (31%)
Grade 4
44 (22%)
Grade 5
10 (5%)
ae_table_grade(df_ae=ae, df_enrol=enrolres, arm="arm") %>%
as_flextable(header_show_n=TRUE)
label
variable
Treatment arm
Total
Control (N=100)
Treatment (N=100)
Patient maximum AE grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade 1
27 (27%)
8 (8%)
35 (18%)
Grade 2
32 (32%)
30 (30%)
62 (31%)
Grade 3
23 (23%)
28 (28%)
51 (26%)
Grade 4
14 (14%)
25 (25%)
39 (20%)
Grade 5
1 (1%)
9 (9%)
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade ≥ 1
97 (97%)
100 (100%)
197 (98%)
Grade ≥ 2
70 (70%)
92 (92%)
162 (81%)
Grade ≥ 3
38 (38%)
62 (62%)
100 (50%)
Grade ≥ 4
15 (15%)
34 (34%)
49 (24%)
Grade = 5
1 (1%)
9 (9%)
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade 1
83 (83%)
81 (81%)
164 (82%)
Grade 2
53 (53%)
64 (64%)
117 (58%)
Grade 3
25 (25%)
37 (37%)
62 (31%)
Grade 4
15 (15%)
29 (29%)
44 (22%)
Grade 5
1 (1%)
9 (9%)
10 (5%)
#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=100)
Treatment (N=100)
Patient maximum SAE grade
No declared SAE
73 (73%)
77 (77%)
150 (75%)
Grade 1
10 (10%)
1 (1%)
11 (6%)
Grade 2
6 (6%)
3 (3%)
9 (4%)
Grade 3
3 (3%)
7 (7%)
10 (5%)
Grade 4
8 (8%)
8 (8%)
16 (8%)
Grade 5
0 (0%)
4 (4%)
4 (2%)
Patient had at least one SAE of grade
No declared SAE
73 (73%)
77 (77%)
150 (75%)
Grade ≥ 1
27 (27%)
23 (23%)
50 (25%)
Grade ≥ 2
17 (17%)
22 (22%)
39 (20%)
Grade ≥ 3
11 (11%)
19 (19%)
30 (15%)
Grade ≥ 4
8 (8%)
12 (12%)
20 (10%)
Grade = 5
0 (0%)
4 (4%)
4 (2%)
Patient had at least one SAE of grade
No declared SAE
73 (73%)
77 (77%)
150 (75%)
Grade 1
10 (10%)
2 (2%)
12 (6%)
Grade 2
8 (8%)
3 (3%)
11 (6%)
Grade 3
5 (5%)
8 (8%)
13 (6%)
Grade 4
8 (8%)
8 (8%)
16 (8%)
Grade 5
0 (0%)
4 (4%)
4 (2%)
#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=100)
Patient maximum AE grade
No declared AE
3 (3%)
3 (3%)
Grade 1
27 (27%)
27 (27%)
Grade 2
32 (32%)
32 (32%)
Grade 3
23 (23%)
23 (23%)
Grade 4
14 (14%)
14 (14%)
Grade 5
1 (1%)
1 (1%)
Patient had at least one AE of grade
No declared AE
3 (3%)
3 (3%)
Grade ≥ 1
97 (97%)
97 (97%)
Grade ≥ 2
70 (70%)
70 (70%)
Grade ≥ 3
38 (38%)
38 (38%)
Grade ≥ 4
15 (15%)
15 (15%)
Grade = 5
1 (1%)
1 (1%)
Patient had at least one AE of grade
No declared AE
3 (3%)
3 (3%)
Grade 1
83 (83%)
83 (83%)
Grade 2
53 (53%)
53 (53%)
Grade 3
25 (25%)
25 (25%)
Grade 4
15 (15%)
15 (15%)
Grade 5
1 (1%)
1 (1%)
#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=100)
Treatment (N=100)
Patient maximum AE grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade 3
23 (23%)
28 (28%)
51 (26%)
Grade 4
14 (14%)
25 (25%)
39 (20%)
Grade 5
1 (1%)
9 (9%)
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade ≥ 1
97 (97%)
100 (100%)
197 (98%)
Grade ≥ 2
70 (70%)
92 (92%)
162 (81%)
Grade ≥ 3
38 (38%)
62 (62%)
100 (50%)
Grade ≥ 4
15 (15%)
34 (34%)
49 (24%)
Grade = 5
1 (1%)
9 (9%)
10 (5%)
Patient had at least one AE of grade
No declared AE
3 (3%)
0 (0%)
3 (2%)
Grade 3
25 (25%)
37 (37%)
62 (31%)
Grade 4
15 (15%)
29 (29%)
44 (22%)
Grade 5
1 (1%)
9 (9%)
10 (5%)