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

FDA Table 09

Patients With Serious Adverse Events by System Organ Class and Preferred Term, Safety Population, Pooled Analyses

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

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

adsl <- random.cdisc.data::cadsl
adae <- random.cdisc.data::cadae

# Pre-processing --------------------------------------------

adae <- adae %>%
  dplyr::filter(
    # safety population
    SAFFL == "Y",
    # serious adverse events
    AESER == "Y"
  )
Code
tbl <- adae |>
  tbl_hierarchical(
    variables = c(AESOC, AEDECOD),
    by = ARM,
    id = USUBJID,
    denominator = adsl,
    overall_row = TRUE,
    label = "..ard_hierarchical_overall.." ~ "Any SAE"
  )
tbl

Code
ard <- gather_ard(tbl)
ard
$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>                                       ARM      A: Drug X categori…         n          n   134      134       0                   stat_1
2    <NA>                <NA>                                       ARM      A: Drug X categori…         N          N   400      400       0                   stat_1
3    <NA>                <NA>                                       ARM      A: Drug X categori…         p          % 0.335     33.5    <fn>                   stat_1
4    <NA>                <NA>                                       ARM      B: Place… categori…         n          n   134      134       0                   stat_2
5    <NA>                <NA>                                       ARM      B: Place… categori…         N          N   400      400       0                   stat_2
6    <NA>                <NA>                                       ARM      B: Place… categori…         p          % 0.335     33.5    <fn>                   stat_2
7    <NA>                <NA>                                       ARM      C: Combi… categori…         n          n   132      132       0                   stat_3
8    <NA>                <NA>                                       ARM      C: Combi… categori…         N          N   400      400       0                   stat_3
9    <NA>                <NA>                                       ARM      C: Combi… categori…         p          %  0.33     33.0    <fn>                   stat_3
10    ARM    A: Drug X   <NA>              ..ard_hierarchical_overall..           TRUE hierarch…         n          n   104      104    <fn>                   stat_1
ℹ 71 more rows
ℹ Use `print(n = ...)` to see more rows
Source Code
---
title: FDA Table 09
subtitle: Patients With Serious Adverse Events by System Organ Class and Preferred Term, Safety Population, Pooled Analyses
categories: [table, FDA, safety, adverse events]
---

::: panel-tabset
## Table Preview

```{r}
#| label: img
#| echo: false
#| fig-align: center
#| out-width: '60%'
knitr::include_graphics("result.png")
```

## Setup

```{r}
#| label: setup
#| message: false
# Load libraries & data -------------------------------------
library(dplyr)
library(gtsummary)

adsl <- random.cdisc.data::cadsl
adae <- random.cdisc.data::cadae

# Pre-processing --------------------------------------------

adae <- adae %>%
  dplyr::filter(
    # safety population
    SAFFL == "Y",
    # serious adverse events
    AESER == "Y"
  )
```


## Build Table

```{r}
#| label: tbl
#| results: hide

tbl <- adae |>
  tbl_hierarchical(
    variables = c(AESOC, AEDECOD),
    by = ARM,
    id = USUBJID,
    denominator = adsl,
    overall_row = TRUE,
    label = "..ard_hierarchical_overall.." ~ "Any SAE"
  )
tbl
```

```{r}
#| eval: false
#| include: false
## ** (OPTIONAL) RUN THIS CHUNK LOCALLY TO GENERATE AN IMAGE FILE **
gt::gtsave(as_gt(tbl), filename = "result.png")
```

```{r}
#| label: img
#| echo: false
#| fig-align: center
#| out-width: '60%'
```

## Build ARD

```{r}
#| label: ard
#| echo: true
#| message: false
#| warning: false
#| results: hide
ard <- gather_ard(tbl)
ard
```

```{r}
#| echo: false
# Print ARD
withr::local_options(width = 9999)
print(ard, columns = "all")
```
:::
 
  • This website as well as code examples are licensed under the Apache License, Version 2.0.
Cookie Preferences