View source: R/ard_hierarchical.R
ard_hierarchical | R Documentation |
Performs hierarchical or nested tabulations, e.g. tabulates AE terms
nested within AE system organ class.
ard_hierarchical()
includes summaries for the last variable listed
in the variables
argument, nested within the other variables included.
ard_hierarchical_count()
includes summaries for all variables
listed in the variables
argument each summary nested within the preceding
variables, e.g. variables=c(AESOC, AEDECOD)
summarizes AEDECOD
nested
in AESOC
, and also summarizes the counts of AESOC
.
ard_hierarchical(data, ...)
ard_hierarchical_count(data, ...)
## S3 method for class 'data.frame'
ard_hierarchical(
data,
variables,
by = dplyr::group_vars(data),
statistic = everything() ~ c("n", "N", "p"),
denominator = NULL,
fmt_fn = NULL,
stat_label = everything() ~ default_stat_labels(),
id = NULL,
...
)
## S3 method for class 'data.frame'
ard_hierarchical_count(
data,
variables,
by = dplyr::group_vars(data),
fmt_fn = NULL,
stat_label = everything() ~ default_stat_labels(),
...
)
data |
( |
... |
Arguments passed to methods. |
variables |
( |
by |
( |
statistic |
( |
denominator |
( |
fmt_fn |
( |
stat_label |
( |
id |
( |
an ARD data frame of class 'card'
By default, the ard_categorical()
function returns the statistics "n"
, "N"
, and
"p"
, where little "n"
are the counts for the variable levels, and big "N"
is
the number of non-missing observations. The default calculation for the
percentage is merely p = n/N
.
However, it is sometimes necessary to provide a different "N"
to use
as the denominator in this calculation. For example, in a calculation
of the rates of various observed adverse events, you may need to update the
denominator to the number of enrolled subjects.
In such cases, use the denominator
argument to specify a new definition
of "N"
, and subsequently "p"
.
The argument expects one of the following inputs:
a data frame. Any columns in the data frame that overlap with the by
/strata
columns will be used to calculate the new "N"
.
an integer. This single integer will be used as the new "N"
a string: one of "column"
, "row"
, or "cell"
. "column"
is equivalent
to denominator=NULL
. "row"
gives 'row' percentages where by
/strata
columns are the 'top' of a cross table, and the variables are the rows.
"cell"
gives percentages where the denominator is the number of non-missing
rows in the source data frame.
a structured data frame. The data frame will include columns from by
/strata
.
The last column must be named "...ard_N..."
. The integers in this column will
be used as the updated "N"
in the calculations.
ard_hierarchical(
data = ADAE |>
dplyr::slice_tail(n = 1L, by = c(USUBJID, TRTA, AESOC, AEDECOD)),
variables = c(AESOC, AEDECOD),
by = TRTA,
id = USUBJID,
denominator = ADSL |> dplyr::rename(TRTA = ARM)
)
ard_hierarchical_count(
data = ADAE,
variables = c(AESOC, AEDECOD),
by = TRTA
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.