View source: R/tbl_hierarchical_rate_by_grade.R
| tbl_hierarchical_rate_by_grade | R Documentation |
A wrapper function for gtsummary::tbl_hierarchical() to calculate rates of highest toxicity grades with the options
to add rows for grade groups and additional summary sections at each variable level.
Only the highest grade level recorded for each subject will be analyzed. Prior to running the function, ensure that
the toxicity grade variable (grade) is a factor variable, with factor levels ordered lowest to highest.
Grades will appear in rows in the order of the factor levels given, with each grade group appearing prior to the first level in its group.
tbl_hierarchical_rate_by_grade(
data,
variables,
denominator,
by = NULL,
id = "USUBJID",
include_overall = everything(),
statistic = everything() ~ "{n} ({p}%)",
label = NULL,
digits = NULL,
sort = "alphanumeric",
filter = NULL,
grade_groups = list(),
grades_exclude = NULL,
keep_zero_rows = FALSE
)
## S3 method for class 'tbl_hierarchical_rate_by_grade'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
data |
( |
variables |
( |
denominator |
( |
by |
( |
id |
( |
include_overall |
( |
statistic |
( |
label |
( |
digits |
( |
sort |
(
Defaults to |
filter |
( |
grade_groups |
( |
grades_exclude |
( |
keep_zero_rows |
( |
x |
( |
last |
(scalar |
col_label |
( |
... |
These dots are for future extensions and must be empty. |
When using the filter argument, the filter will be applied to the second variable from variables, i.e. the
adverse event terms variable. If an AE does not meet the filtering criteria, the AE overall row as well as all grade
and grade group rows within an AE section will be excluded from the table. Filtering out AEs does not exclude the
records corresponding to these filtered out rows from being included in rate calculations for overall sections. If
all AEs for a given SOC have been filtered out, the SOC will be excluded from the table. If all AEs are filtered out
and the SOC variable is included in include_overall the - Any adverse events - section will still be kept.
See gtsummary::filter_hierarchical() for more details and examples.
a gtsummary table of class "tbl_hierarchical_rate_by_grade".
theme_gtsummary_roche()
ADSL <- cards::ADSL
ADAE_subset <- cards::ADAE |>
dplyr::filter(
AESOC %in% unique(cards::ADAE$AESOC)[1:5],
AETERM %in% unique(cards::ADAE$AETERM)[1:10]
)
grade_groups <- list(
"Grade 1-2" = c("1", "2"),
"Grade 3-4" = c("3", "4"),
"Grade 5" = "5"
)
# Example 1 ----------------------------------
tbl_hierarchical_rate_by_grade(
ADAE_subset,
variables = c(AEBODSYS, AEDECOD, AETOXGR),
denominator = ADSL,
by = TRTA,
label = list(
AEBODSYS = "MedDRA System Organ Class",
AEDECOD = "MedDRA Preferred Term",
AETOXGR = "Grade"
),
grade_groups = grade_groups,
grades_exclude = "5"
)
# Example 2 ----------------------------------
# Filter: Keep AEs with an overall prevalence of greater than 10%
tbl_hierarchical_rate_by_grade(
ADAE_subset,
variables = c(AEBODSYS, AEDECOD, AETOXGR),
denominator = ADSL,
by = TRTA,
grade_groups = list("Grades 1-2" = c("1", "2"), "Grades 3-5" = c("3", "4", "5")),
filter = sum(n) / sum(N) > 0.10
) |>
add_overall(last = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.