cardinal
  • Home
  • Template Catalog
  • About
  • Resources
  • Help
    • Getting Started
    • Report a Bug
    • FAQ

Subjects With Adverse Events Leading to Treatment Discontinuation by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X)

FDA Table 12

table
FDA
safety
adverse events
  • Table Preview
  • Setup
  • Build ARD
  • Build Table

Code
# Load libraries & data -------------------------------------
library(dplyr)
library(cards)
library(gtsummary)

adsl <- random.cdisc.data::cadsl
adae <- random.cdisc.data::cadae
adae$DCSREAS[is.na(adae$DCSREAS)] <- "ADVERSE EVENT"

# Pre-processing --------------------------------------------
adsl <- adsl |>
  filter(SAFFL == "Y") # safety population

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # discontinuation due to AE
    DCSREAS == "ADVERSE EVENT"
  )
Code
ard <- ard_stack_hierarchical(
  data,
  variables = c(AEBODSYS, AEDECOD),
  by = TRT01A,
  denominator = adsl,
  id = USUBJID
)

ard
{cards} data frame: 162 x 13
   group1 group1_level   group2 group2_level variable variable_level   context stat_name stat_label  stat fmt_fun warning error
1    <NA>                  <NA>                TRT01A      A: Drug X  tabulate         n          n   134       0              
2    <NA>                  <NA>                TRT01A      A: Drug X  tabulate         N          N   400       0              
3    <NA>                  <NA>                TRT01A      A: Drug X  tabulate         p          % 0.335    <fn>              
4    <NA>                  <NA>                TRT01A      B: Place…  tabulate         n          n   134       0              
5    <NA>                  <NA>                TRT01A      B: Place…  tabulate         N          N   400       0              
6    <NA>                  <NA>                TRT01A      B: Place…  tabulate         p          % 0.335    <fn>              
7    <NA>                  <NA>                TRT01A      C: Combi…  tabulate         n          n   132       0              
8    <NA>                  <NA>                TRT01A      C: Combi…  tabulate         N          N   400       0              
9    <NA>                  <NA>                TRT01A      C: Combi…  tabulate         p          %  0.33    <fn>              
10 TRT01A    A: Drug X     <NA>              AEBODSYS         cl A.1 hierarch…         n          n    53       0              
11 TRT01A    A: Drug X     <NA>              AEBODSYS         cl A.1 hierarch…         N          N   134       0              
12 TRT01A    A: Drug X     <NA>              AEBODSYS         cl A.1 hierarch…         p          % 0.396    <fn>              
13 TRT01A    B: Place…     <NA>              AEBODSYS         cl A.1 hierarch…         n          n    55       0              
14 TRT01A    B: Place…     <NA>              AEBODSYS         cl A.1 hierarch…         N          N   134       0              
15 TRT01A    B: Place…     <NA>              AEBODSYS         cl A.1 hierarch…         p          %  0.41    <fn>              
16 TRT01A    C: Combi…     <NA>              AEBODSYS         cl A.1 hierarch…         n          n    69       0              
17 TRT01A    C: Combi…     <NA>              AEBODSYS         cl A.1 hierarch…         N          N   132       0              
18 TRT01A    C: Combi…     <NA>              AEBODSYS         cl A.1 hierarch…         p          % 0.523    <fn>              
19 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    37       0              
20 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   134       0              
21 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.276    <fn>              
22 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    37       0              
23 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   134       0              
24 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.276    <fn>              
25 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    50       0              
26 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   132       0              
27 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.379    <fn>              
28 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    33       0              
29 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   134       0              
30 TRT01A    A: Drug X AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.246    <fn>              
31 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    31       0              
32 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   134       0              
33 TRT01A    B: Place… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.231    <fn>              
34 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         n          n    40       0              
35 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         N          N   132       0              
36 TRT01A    C: Combi… AEBODSYS       cl A.1  AEDECOD      dcd A.1.… hierarch…         p          % 0.303    <fn>              
37 TRT01A    A: Drug X     <NA>              AEBODSYS         cl B.1 hierarch…         n          n    35       0              
38 TRT01A    A: Drug X     <NA>              AEBODSYS         cl B.1 hierarch…         N          N   134       0              
39 TRT01A    A: Drug X     <NA>              AEBODSYS         cl B.1 hierarch…         p          % 0.261    <fn>              
40 TRT01A    B: Place…     <NA>              AEBODSYS         cl B.1 hierarch…         n          n    41       0              
ℹ 122 more rows
ℹ Use `print(n = ...)` to see more rows
Code
tbl <- tbl_hierarchical(
  data,
  variables = c(AEBODSYS, AEDECOD),
  by = TRT01A,
  id = USUBJID,
  denominator = adsl,
  overall_row = TRUE,
  label = list(..ard_hierarchical_overall.. = "Subjects with at least one AE leading to treatment discontinuation")
)

tbl

Source Code
---
title: Subjects With Adverse Events Leading to Treatment Discontinuation by System Organ Class and Preferred Term, Safety Population, Pooled Analysis (or Trial X) 
subtitle: FDA Table 12
categories: [table, FDA, safety, adverse events]
---

::: panel-tabset
## Table Preview

```{r img, echo=FALSE, fig.align='center', out.width='70%'}
knitr::include_graphics("result.png")
```

## Setup

```{r setup, message=FALSE}
# Load libraries & data -------------------------------------
library(dplyr)
library(cards)
library(gtsummary)

adsl <- random.cdisc.data::cadsl
adae <- random.cdisc.data::cadae
adae$DCSREAS[is.na(adae$DCSREAS)] <- "ADVERSE EVENT"

# Pre-processing --------------------------------------------
adsl <- adsl |>
  filter(SAFFL == "Y") # safety population

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # discontinuation due to AE
    DCSREAS == "ADVERSE EVENT"
  )
```

## Build ARD

```{r ard, message=FALSE, warning=FALSE, results='hide'}
ard <- ard_stack_hierarchical(
  data,
  variables = c(AEBODSYS, AEDECOD),
  by = TRT01A,
  denominator = adsl,
  id = USUBJID
)

ard
```

```{r, echo=FALSE}
# Print ARD
withr::local_options(width = 9999)
print(ard, columns = "all", n = 40)
```

## Build Table

```{r tbl, results = 'hide'}
tbl <- tbl_hierarchical(
  data,
  variables = c(AEBODSYS, AEDECOD),
  by = TRT01A,
  id = USUBJID,
  denominator = adsl,
  overall_row = TRUE,
  label = list(..ard_hierarchical_overall.. = "Subjects with at least one AE leading to treatment discontinuation")
)

tbl
```

```{r eval=FALSE, include=FALSE}
# Run chunk locally to generate image file
gt::gtsave(as_gt(tbl), filename = "result.png")
```

```{r img, echo=FALSE, fig.align='center', out.width='70%'}
```
:::
 
  • This website as well as code examples are licensed under the Apache License, Version 2.0.
Cookie Preferences