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

FDA Table 09

All Individual Subject Deaths, Safety Population, Pooled Analysis (or Trial X)

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

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

adae <- pharmaverseadam::adae
adex <- pharmaverseadam::adex

# Pre-processing --------------------------------------------
# deaths
adae <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # deaths
    DTHFL == "Y"
  ) |>
  # select variables from `adae` to include in final result
  select(USUBJID, TRT01A, AGE, SEX, DTHADY, DTHCAUS) |>
  # keep one row per unique ID
  distinct(USUBJID, DTHCAUS, DTHADY, .keep_all = TRUE)

# dosing
adex <- adex |>
  filter(
    # safety population
    SAFFL == "Y",
    # total dosages
    PARAMCD == "TDOSE"
  ) |>
  # select variables from `adex` to include in final result
  select(USUBJID, AVAL, TRTSDT, TRTEDT) |>
  mutate(
    # derive dosage duration
    DOSDUR = (TRTEDT - TRTSDT + 1) |> as.character()
  )

# combine all data
data <- left_join(adae, adex, by = "USUBJID") |>
  select(TRT01A, USUBJID, AGE, SEX, DOSDUR, DTHADY, DTHCAUS) |>
  arrange()
Code
tbl <- as_gtsummary(data) |>
  # set table header labels
  modify_header(
    TRT01A = "**Treatment Arm**",
    USUBJID = "**Unique  \n Subject ID**",
    AGE = "**Age**",
    SEX = "**Sex**",
    DOSDUR = "**Dosing**  \n **Duration**  \n **(Days)**",
    DTHADY = "**Study**  \n **Day of**  \n **Death**",
    DTHCAUS = "**Cause of Death**"
  ) |>
  # align all columns left
  modify_column_alignment(everything(), align = "left")

tbl

Code
# For this table we do not build an ARD since we are returning the complete
# dataset as our result, so there are no statistics to display in an ARD.
# The full unformatted dataset (`data`) can be used instead if needed
data
# A tibble: 3 × 7
  TRT01A              USUBJID       AGE SEX   DOSDUR DTHADY DTHCAUS              
  <chr>               <chr>       <dbl> <chr> <chr>   <dbl> <chr>                
1 Xanomeline Low Dose 01-701-1211    76 F     59         61 SUDDEN DEATH         
2 Placebo             01-704-1445    75 M     175       175 COMPLETED SUICIDE    
3 Placebo             01-710-1083    89 F     11         12 MYOCARDIAL INFARCTION
Source Code
---
title: FDA Table 09
subtitle: All Individual Subject Deaths, Safety Population, Pooled Analysis (or Trial X) 
categories: [table, FDA, safety, adverse events]
---

::: panel-tabset
## Table Preview

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

## Setup

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

adae <- pharmaverseadam::adae
adex <- pharmaverseadam::adex

# Pre-processing --------------------------------------------
# deaths
adae <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # deaths
    DTHFL == "Y"
  ) |>
  # select variables from `adae` to include in final result
  select(USUBJID, TRT01A, AGE, SEX, DTHADY, DTHCAUS) |>
  # keep one row per unique ID
  distinct(USUBJID, DTHCAUS, DTHADY, .keep_all = TRUE)

# dosing
adex <- adex |>
  filter(
    # safety population
    SAFFL == "Y",
    # total dosages
    PARAMCD == "TDOSE"
  ) |>
  # select variables from `adex` to include in final result
  select(USUBJID, AVAL, TRTSDT, TRTEDT) |>
  mutate(
    # derive dosage duration
    DOSDUR = (TRTEDT - TRTSDT + 1) |> as.character()
  )

# combine all data
data <- left_join(adae, adex, by = "USUBJID") |>
  select(TRT01A, USUBJID, AGE, SEX, DOSDUR, DTHADY, DTHCAUS) |>
  arrange()
```

## Build Table

```{r tbl, results = 'hide'}
tbl <- as_gtsummary(data) |>
  # set table header labels
  modify_header(
    TRT01A = "**Treatment Arm**",
    USUBJID = "**Unique  \n Subject ID**",
    AGE = "**Age**",
    SEX = "**Sex**",
    DOSDUR = "**Dosing**  \n **Duration**  \n **(Days)**",
    DTHADY = "**Study**  \n **Day of**  \n **Death**",
    DTHCAUS = "**Cause of Death**"
  ) |>
  # align all columns left
  modify_column_alignment(everything(), align = "left")

tbl
```

```{r eval=FALSE, include=FALSE}
gt::gtsave(as_gt(tbl), filename = "result.png")
```

```{r img, echo=FALSE, fig.align='center', out.width='60%'}
```

## Build ARD

```{r ard, message=FALSE, warning=FALSE, results='hide'}
# For this table we do not build an ARD since we are returning the complete
# dataset as our result, so there are no statistics to display in an ARD.
# The full unformatted dataset (`data`) can be used instead if needed
data
```

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