The function ae_table_soc()
creates a summary table of maximum AE grades for each patient according to term and SOC CTCAE.
The resulting dataframe can be piped to as_flextable()
to get a nicely formatted flextable.
ae_table_soc(
df_ae,
...,
df_enrol,
variant = c("max", "sup", "eq"),
arm = NULL,
term = NULL,
sort_by_count = TRUE,
total = TRUE,
showNA = TRUE,
digits = 0,
warn_miss = FALSE,
grade = "AEGR",
soc = "AESOC",
subjid = "SUBJID"
)
# S3 method for class 'ae_table_soc'
as_flextable(
x,
arm_colors = c("#f2dcdb", "#dbe5f1", "#ebf1dd", "#e5e0ec"),
padding_v = NULL
)
adverse event dataset, one row per AE, containing subjid, soc, and grade.
unused
enrollment dataset, one row per patient, containing subjid (and arm if needed). All patients should be in this dataset.
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.
name of the treatment column in df_enrol
. Case-insensitive. Can be set to NULL
.
name of the the CTCAE term column in df_ae
. Case-insensitive. Can be set to NULL
.
should the table be sorted by the number of AE or by SOC alphabetically.
whether to add a total
column for each arm.
whether to display missing grades.
significant digits for percentages.
whether to warn for missing values.
name of the AE grade column in df_ae
. Case-insensitive.
name of the SOC column in df_ae
. Case-insensitive. Grade will be considered 0 if missing (e.g. if patient if absent from df_ae
).
name of the patient ID in both df_ae
and df_enrol
. Case-insensitive.
a dataframe, resulting of ae_table_soc()
colors for the arm groups
a numeric of lenght up to 2, giving the vertical padding of body (1) and header (2)
ae_table_grade()
, ae_table_soc()
, ae_plot_grade()
, ae_plot_grade_sum()
, butterfly_plot()
tm = grstat_example()
attach(tm, warn.conflicts=FALSE)
ae_table_soc(df_ae=ae, df_enrol=enrolres)
#> Warning: Unknown or uninitialised column: `grade`.
#> Error in ae_table_soc(df_ae = ae, df_enrol = enrolres): Grade ("AEGR") should be a numeric column.
ae_table_soc(df_ae=ae, df_enrol=enrolres, arm="arm")
#> Warning: Unknown or uninitialised column: `grade`.
#> Error in ae_table_soc(df_ae = ae, df_enrol = enrolres, arm = "arm"): Grade ("AEGR") should be a numeric column.
#sub population
ae_table_soc(df_ae=ae, df_enrol=head(enrolres, 10), arm="arm")
#> Warning: Unknown or uninitialised column: `grade`.
#> Error in ae_table_soc(df_ae = ae, df_enrol = head(enrolres, 10), arm = "arm"): Grade ("AEGR") should be a numeric column.
#the resulting flextable can be customized using the flextable package
ae_table_soc(ae, df_enrol=enrolres, total=FALSE) %>%
as_flextable() %>%
hline(i=~soc=="" & soc!=dplyr::lead(soc))
#> Error in hline(., i = ~soc == "" & soc != dplyr::lead(soc)): could not find function "hline"
ae_table_soc(ae, df_enrol=enrolres, term=NULL, sort_by_count=FALSE) %>%
as_flextable() %>%
bold(i=~soc=="Eye disorders")
#> Error in bold(., i = ~soc == "Eye disorders"): could not find function "bold"
ae_table_soc(ae, df_enrol=enrolres, term=NULL, arm=NULL) %>%
as_flextable() %>%
highlight(i=~soc=="Hepatobiliary disorders", j="all_patients_Tot")
#> Error in highlight(., i = ~soc == "Hepatobiliary disorders", j = "all_patients_Tot"): could not find function "highlight"