View source: R/ard_mvsummary.R
| ard_mvsummary | R Documentation |
Function is similar to ard_summary(), but allows for more complex, multivariate
summaries. While ard_summary(statistic) only allows for a univariable
function, ard_mvsummary(statistic) can handle more complex data summaries.
ard_mvsummary(data, ...)
## S3 method for class 'data.frame'
ard_mvsummary(
data,
variables,
by = dplyr::group_vars(data),
strata = NULL,
statistic,
fmt_fun = NULL,
stat_label = everything() ~ default_stat_labels(),
fmt_fn = deprecated(),
...
)
data |
( |
... |
Arguments passed to methods. |
variables |
( |
by, strata |
(
Arguments may be used in conjunction with one another. |
statistic |
(
It is unlikely any one function will need all of the above elements,
and it's recommended the function passed accepts |
fmt_fun |
( |
stat_label |
( |
fmt_fn |
an ARD data frame of class 'card'
# example how to mimic behavior of `ard_summary()`
ard_mvsummary(
ADSL,
by = "ARM",
variables = "AGE",
statistic = list(AGE = list(mean = \(x, ...) mean(x)))
)
# return the grand mean and the mean within the `by` group
grand_mean <- function(data, full_data, variable, ...) {
list(
mean = mean(data[[variable]], na.rm = TRUE),
grand_mean = mean(full_data[[variable]], na.rm = TRUE)
)
}
ADSL |>
dplyr::group_by(ARM) |>
ard_mvsummary(
variables = "AGE",
statistic = list(AGE = list(means = grand_mean))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.