
Subjects With Adverse Events by Male-Specific OCMQ (Narrow) and Preferred Term, Male Safety Population, Pooled Analysis (or Trial X)
FDA Table 33
table
FDA
safety
adverse events
Code
# Load libraries & data -------------------------------------
library(dplyr)
library(cards)
library(gtsummary)
adsl <- pharmaverseadam::adsl
adae <- pharmaverseadam::adae
set.seed(1)
adae <- rename(adae, OCMQ01SC = AEHLTCD, OCMQ01NAM = AEHLT)
levels(adae$OCMQ01SC) <- c("BROAD", "NARROW")
adae$OCMQ01SC[is.na(adae$OCMQ01SC)] <- "NARROW"
adae$OCMQ01NAM <- factor(adae$OCMQ01NAM, levels = c("Erectile Dysfunction", "Gynecomastia"))
adae$OCMQ01NAM[adae$SEX == "M"] <- as.factor(sample(c("Erectile Dysfunction", "Gynecomastia"), sum(adae$SEX == "M"), replace = TRUE))
# Pre-processing --------------------------------------------
data <- adae |>
filter(
SAFFL == "Y",
SEX == "M",
OCMQ01SC == "NARROW",
# filtering here to reduce the size of the table
AEDECOD %in% c("COUGH", "COLD SWEAT", "SOMNOLENCE", "APPLICATION SITE ERYTHEMA")
) |>
select(OCMQ01SC, TRT01A, OCMQ01NAM, AEDECOD, USUBJID) |>
# setting an explicit level for NA values so empty strata combinations are shown.
mutate(across(everything(), ~ {
if (anyNA(.)) {
forcats::fct_na_value_to_level(as.factor(.), level = "<Missing>")
} else {
.
}
}))
# denominator values include only Male subjects in the arm with AEs
denom <- data |> distinct(USUBJID, TRT01A)
$tbl_hierarchical
{cards} data frame: 81 x 15
group1 group1_level group2 group2_level variable variable_level context stat_name stat_label stat stat_fmt fmt_fun warning error gts_column
1 <NA> <NA> TRT01A Placebo tabulate n n 6 6 0 stat_1
2 <NA> <NA> TRT01A Placebo tabulate N N 29 29 0 stat_1
3 <NA> <NA> TRT01A Placebo tabulate p % 0.207 20.7 <fn> stat_1
4 <NA> <NA> TRT01A Xanomeli… tabulate n n 12 12 0 stat_2
5 <NA> <NA> TRT01A Xanomeli… tabulate N N 29 29 0 stat_2
6 <NA> <NA> TRT01A Xanomeli… tabulate p % 0.414 41.4 <fn> stat_2
7 <NA> <NA> TRT01A Xanomeli… tabulate n n 11 11 0 stat_3
8 <NA> <NA> TRT01A Xanomeli… tabulate N N 29 29 0 stat_3
9 <NA> <NA> TRT01A Xanomeli… tabulate p % 0.379 37.9 <fn> stat_3
10 TRT01A Placebo OCMQ01NAM Erectile… AEDECOD APPLICAT… hierarch… n n 0 0 <fn> stat_1
ℹ 71 more rows
ℹ Use `print(n = ...)` to see more rows