View source: R/ard_stack_hierarchical.R
ard_stack_hierarchical | R Documentation |
Use these functions to calculate multiple summaries of nested or hierarchical data
in a single call.
ard_stack_hierarchical()
: Calculates rates of events (e.g. adverse events)
utilizing the denominator
and id
arguments to identify the rows in data
to include in each rate calculation.
ard_stack_hierarchical_count()
: Calculates counts of events utilizing
all rows for each tabulation.
ard_stack_hierarchical(
data,
variables,
by = dplyr::group_vars(data),
id,
denominator,
include = everything(),
statistic = everything() ~ c("n", "N", "p"),
overall = FALSE,
over_variables = FALSE,
attributes = FALSE,
total_n = FALSE,
shuffle = FALSE
)
ard_stack_hierarchical_count(
data,
variables,
by = dplyr::group_vars(data),
denominator = NULL,
include = everything(),
overall = FALSE,
over_variables = FALSE,
attributes = FALSE,
total_n = FALSE,
shuffle = FALSE
)
data |
( |
variables |
( |
by |
( |
id |
( |
denominator |
(
|
include |
( |
statistic |
( |
overall |
(scalar |
over_variables |
(scalar |
attributes |
(scalar |
total_n |
(scalar |
shuffle |
(scalar |
an ARD data frame of class 'card'
To calculate event rates, the ard_stack_hierarchical()
function identifies
rows to include in the calculation.
First, the primary data frame is sorted by the columns identified in
the id
, by
, and variables
arguments.
As the function cycles over the variables specified in the variables
argument,
the data frame is grouped by id
, intersect(by, names(denominator))
, and variables
utilizing the last row within each of the groups.
For example, if the call is
ard_stack_hierarchical(data = ADAE, variables = c(AESOC, AEDECOD), id = USUBJID)
,
then we'd first subset ADAE to be one row within the grouping c(USUBJID, AESOC, AEDECOD)
to calculate the event rates in 'AEDECOD'
. We'd then repeat and
subset ADAE to be one row within the grouping c(USUBJID, AESOC)
to calculate the event rates in 'AESOC'
.
When we set overall=TRUE
, we wish to re-run our calculations removing the
stratifying columns. For example, if we ran the code below, we results would
include results with the code chunk being re-run with by=NULL
.
ard_stack_hierarchical( data = ADAE, variables = c(AESOC, AEDECOD), by = TRTA, denominator = ADSL |> dplyr::rename(TRTA = ARM), overall = TRUE )
But there is another case to be aware of: when the by
argument includes
columns that are not present in the denominator
, for example when tabulating
results by AE grade or severity in addition to treatment assignment.
In the example below, we're tabulating results by treatment assignment and
AE severity. By specifying overall=TRUE
, we will re-run the to get
results with by = AESEV
and again with by = NULL
.
ard_stack_hierarchical( data = ADAE, variables = c(AESOC, AEDECOD), by = c(TRTA, AESEV), denominator = ADSL |> dplyr::rename(TRTA = ARM), overall = TRUE )
ard_stack_hierarchical(
ADAE,
variables = c(AESOC, AEDECOD),
by = TRTA,
denominator = ADSL |> dplyr::rename(TRTA = ARM),
id = USUBJID
)
ard_stack_hierarchical_count(
ADAE,
variables = c(AESOC, AEDECOD),
by = TRTA,
denominator = ADSL |> dplyr::rename(TRTA = ARM)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.