FDA Table 3
Patient Screening and Enrollment, Trials A and B
table
FDA
safety
disposition
Code
# Load libraries & data -------------------------------------
library(dplyr)
library(formatters)
library(cards)
library(gtsummary)
adsl <- random.cdisc.data::cadsl
set.seed(1)
adsl$RANDDT[sample(seq_len(nrow(adsl)), 100)] <- NA
scrnfail_reas_lvls <- c(
"Inclusion/exclusion criteria not met", "Patient noncompliance", "Consent withdrawn", "Other"
)
data <- adsl |>
mutate(
ENRLDT = RANDDT,
SCRNFL = with_label(TRUE, "Patients screened"),
SCRNFRS = factor(sample(scrnfail_reas_lvls, size = nrow(adsl), replace = TRUE),
levels = scrnfail_reas_lvls
),
ENRLFL = with_label(!is.na(ENRLDT), "Patients enrolled"),
RANDFL = with_label(!is.na(RANDDT), "Patients randomized")
)
data$SCRNFRS[data$SCRNFL == "N" | !is.na(data$ENRLDT)] <- NA
Code
ard <- data |>
ard_stack(
ard_dichotomous(
variables = SCRNFL,
value = list(SCRNFL = TRUE),
statistic = everything() ~ c("n")
),
ard_categorical(
variables = SCRNFRS,
statistic = everything() ~ c("n", "p"),
denominator = data
),
ard_dichotomous(
variables = c(ENRLFL, RANDFL),
value = list(ENRLFL = TRUE, RANDFL = TRUE),
statistic = everything() ~ c("n", "p"),
denominator = data
)
)
ard
{cards} data frame: 13 x 9
variable variable_level context stat_name stat_label stat fmt_fun warning error
1 SCRNFL TRUE dichotom… n n 400 0
2 SCRNFRS Inclusio… categori… n n 26 0
3 SCRNFRS Inclusio… categori… p % 0.065 <fn>
4 SCRNFRS Patient … categori… n n 20 0
5 SCRNFRS Patient … categori… p % 0.05 <fn>
6 SCRNFRS Consent … categori… n n 30 0
7 SCRNFRS Consent … categori… p % 0.075 <fn>
8 SCRNFRS Other categori… n n 24 0
9 SCRNFRS Other categori… p % 0.06 <fn>
10 ENRLFL TRUE dichotom… n n 300 0
11 ENRLFL TRUE dichotom… p % 0.75 <fn>
12 RANDFL TRUE dichotom… n n 300 0
13 RANDFL TRUE dichotom… p % 0.75 <fn>
Code
tbl_scrn <- tbl_summary(
data = data,
include = "SCRNFL",
statistic = SCRNFL ~ "{n}",
missing = "no"
)
tbl_scrnfrs <- tbl_hierarchical(
data = data,
denominator = adsl,
id = USUBJID,
variables = "SCRNFRS",
statistic = ~"{n} ({p}%)",
label = list(..ard_hierarchical_overall.. = "Screening failures"),
overall_row = TRUE
)
tbl_enrl_rand <- tbl_summary(
data = data,
include = c("ENRLFL", "RANDFL"),
missing = "no"
)
tbl <- list(tbl_scrn, tbl_scrnfrs, tbl_enrl_rand) |>
tbl_stack() |>
modify_header(label = "**Disposition**", stat_0 = "**Trial A**") |>
modify_column_indent("label", rows = !(variable %in% c("..ard_hierarchical_overall..", "SCRNFL", "ENRLFL", "RANDFL"))) |>
remove_footnote_header(columns = everything())
tbl