# Add labelled flag variables to analysis dataset.
adae <- tern_ex_adae %>%
dplyr::mutate(
fl1 = TRUE %>% with_label("Total AEs"),
fl2 = (TRTEMFL == "Y") %>%
with_label("Total number of patients with at least one adverse event"),
fl3 = (TRTEMFL == "Y" & AEOUT == "FATAL") %>%
with_label("Total number of patients with fatal AEs"),
fl4 = (TRTEMFL == "Y" & AEOUT == "FATAL" & AEREL == "Y") %>%
with_label("Total number of patients with related fatal AEs")
)
lyt <- basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
count_patients_with_flags(
"SUBJID",
flag_variables = c("fl1", "fl2", "fl3", "fl4"),
denom = "N_col"
)
build_table(lyt, adae, alt_counts_df = tern_ex_adsl)
# `s_count_patients_with_flags()`
s_count_patients_with_flags(
adae,
"SUBJID",
flag_variables = c("fl1", "fl2", "fl3", "fl4"),
denom = "N_col",
.N_col = 1000
)
a_count_patients_with_flags(
adae,
.N_col = 10L,
.N_row = 10L,
.var = "USUBJID",
flag_variables = c("fl1", "fl2", "fl3", "fl4")
)
Run the code above in your browser using DataLab