treatments <- factor(c("a", "b", "c"))
ae_severities <- c("Missing", "Mild", "Moderate", "Severe")
ae_severities <- ordered(ae_severities, levels = ae_severities)
my_adae <- data.frame(
ID = c(1, 1, 1, 2, 2, 3, 3, 3, 3, 4),
TRT = factor(c("a", "b", "b", "b", "c", "c", "a", "c", "b", "b")),
AESEV = ae_severities[c(4L, 1L, 2L, 1L, 2L, 1L, 2L, 3L, 1L, 2L)]
)
my_adsl <- data.frame(
ID = rep(1:5, each = 3),
TRT = factor(rep(c("a", "b", "c"), times = 5))
)
aesevall_spf <- make_combo_splitfun(
nm = "AESEV_ALL",
label = "Any AE",
levels = NULL,
)
lyt <- basic_table() |>
split_cols_by("TRT") |>
add_overall_col("Total") |>
split_rows_by("AESEV", split_fun = aesevall_spf) |>
summarize_row_groups(
"AESEV",
cfun = a_maxlev,
extra_args = list(id = "ID", any_level = TRUE)
) |>
analyze(
"AESEV",
afun = a_maxlev,
extra_args = list(id = "ID")
)
build_table(lyt, my_adae, alt_counts_df = my_adsl)
Run the code above in your browser using DataLab