# example how to mimic behavior of `ard_continuous()`
ard_complex(
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_complex(
variables = "AGE",
statistic = list(AGE = list(means = grand_mean))
)
Run the code above in your browser using DataLab