FDA Table 03
Subject Screening and Enrollment, Screening Population, Trials A and B
table
FDA
safety
disposition
Code
# Load libraries & data -------------------------------------
library(dplyr)
library(formatters)
library(cards)
library(gtsummary)
adsl <- pharmaverseadam::adsl
set.seed(1)
adsl$RANDDT[sample(seq_len(nrow(adsl)), 100)] <- NA
scrnfail_reas_lvls <- c(
"Inclusion/exclusion criteria not met", "Subject noncompliance", "Consent withdrawn", "Other"
)
data <- adsl |>
mutate(
ENRLDT = RANDDT,
SCRNFL = with_label(TRUE, "Subjects screened"),
SCRNFRS = factor(sample(scrnfail_reas_lvls, size = nrow(adsl), replace = TRUE),
levels = scrnfail_reas_lvls
),
ENRLFL = with_label(!is.na(ENRLDT), "Subjects enrolled"),
RANDFL = with_label(!is.na(RANDDT), "Subjects randomized"),
screen_fail = !ENRLFL # create a flag for screen failure
)
data$SCRNFRS[data$SCRNFL == "N" | !is.na(data$ENRLDT)] <- NA
Code
tbl <- data |>
tbl_summary(
include = c(SCRNFL, screen_fail, SCRNFRS, ENRLFL, RANDFL),
# suppress number of missing observations
missing = "no",
# specify the denominator is always the no. obs. in `data`
percent = data,
# present SCRNFRS in descending order of frequency
sort = SCRNFRS ~ "frequency",
# update default screen failure label
label = list(screen_fail = "Screening failures")
) |>
# remove the blank header row for SCRNFRS
remove_row_type(SCRNFRS, type = "header") |>
modify_header(
label = "**Disposition**",
stat_0 = "**Trial A** \n N = {n}"
) |>
# update indentation for screening failures subsection
modify_indent(columns = label, rows = variable == "screen_fail", indent = 4L) |>
modify_indent(columns = label, rows = variable == "SCRNFRS", indent = 8L)
tbl
$tbl_summary
{cards} data frame: 61 x 10
variable variable_level context stat_name stat_label stat
1 SCRNFRS Inclusio… tabulate n n 40
2 SCRNFRS Inclusio… tabulate N N 306
3 SCRNFRS Inclusio… tabulate p % 0.131
4 SCRNFRS Other tabulate n n 35
5 SCRNFRS Other tabulate N N 306
6 SCRNFRS Other tabulate p % 0.114
7 SCRNFRS Consent … tabulate n n 33
8 SCRNFRS Consent … tabulate N N 306
9 SCRNFRS Consent … tabulate p % 0.108
10 SCRNFRS Subject … tabulate n n 27
ℹ 51 more rows
ℹ Use `print(n = ...)` to see more rows
ℹ 4 more variables: fmt_fun, warning, error, gts_column