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

FDA Table 08

Deaths, Safety Population, Pooled Analysis (or Trial X)

table
FDA
safety
deaths
  • Table Preview
  • Setup
  • Build Table
  • Build ARD

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

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

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

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # deaths
    DTHFL == "Y"
  )
Code
tbl_dthcaus <- data |>
  tbl_hierarchical(
    variables = DTHCAUS,
    id = USUBJID,
    by = TRT01A,
    denominator = adsl,
    overall_row = TRUE,
    label = list("..ard_hierarchical_overall.." = "Death details", DTHCAUS = "**Deaths**")
  ) |>
  sort_hierarchical() |>
  modify_indent(columns = label, rows = variable == "DTHCAUS", indent = 4L)

tbl_aesdth <- data |>
  filter(AESDTH == "Y") |>
  tbl_hierarchical(
    variables = AEDECOD,
    id = USUBJID,
    by = TRT01A,
    denominator = adsl,
    overall_row = TRUE,
    label = list("..ard_hierarchical_overall.." = "Adverse events with an outcome of death", AEDECOD = "**Deaths**")
  ) |>
  sort_hierarchical() |>
  modify_indent(columns = label, rows = variable == "AEDECOD", indent = 4L)

tbl <- tbl_stack(list(tbl_dthcaus, tbl_aesdth))

tbl

Code
ard <- gather_ard(tbl)
ard
[[1]]
[[1]]$tbl_hierarchical
{cards} data frame: 81 x 13
   group1 group1_level                     variable variable_level stat_name stat_label  stat stat_fmt
1    <NA>                                    TRT01A      A: Drug X         n          n   134      134
2    <NA>                                    TRT01A      A: Drug X         N          N   400      400
3    <NA>                                    TRT01A      A: Drug X         p          % 0.335     33.5
4    <NA>                                    TRT01A      B: Place…         n          n   134      134
5    <NA>                                    TRT01A      B: Place…         N          N   400      400
6    <NA>                                    TRT01A      B: Place…         p          % 0.335     33.5
7    <NA>                                    TRT01A      C: Combi…         n          n   132      132
8    <NA>                                    TRT01A      C: Combi…         N          N   400      400
9    <NA>                                    TRT01A      C: Combi…         p          %  0.33     33.0
10 TRT01A    A: Drug X ..ard_hierarchical_overall..           TRUE         n          n    24       24
ℹ 71 more rows
ℹ Use `print(n = ...)` to see more rows
ℹ 5 more variables: context, fmt_fun, warning, error, gts_column


[[2]]
[[2]]$tbl_hierarchical
{cards} data frame: 36 x 13
   group1 group1_level                     variable variable_level stat_name stat_label  stat stat_fmt
1    <NA>                                    TRT01A      A: Drug X         n          n   134      134
2    <NA>                                    TRT01A      A: Drug X         N          N   400      400
3    <NA>                                    TRT01A      A: Drug X         p          % 0.335     33.5
4    <NA>                                    TRT01A      B: Place…         n          n   134      134
5    <NA>                                    TRT01A      B: Place…         N          N   400      400
6    <NA>                                    TRT01A      B: Place…         p          % 0.335     33.5
7    <NA>                                    TRT01A      C: Combi…         n          n   132      132
8    <NA>                                    TRT01A      C: Combi…         N          N   400      400
9    <NA>                                    TRT01A      C: Combi…         p          %  0.33     33.0
10 TRT01A    A: Drug X ..ard_hierarchical_overall..           TRUE         n          n    18       18
ℹ 26 more rows
ℹ Use `print(n = ...)` to see more rows
ℹ 5 more variables: context, fmt_fun, warning, error, gts_column
Source Code
---
title: FDA Table 08
subtitle: Deaths, Safety Population, Pooled Analysis (or Trial X) 
categories: [table, FDA, safety, deaths]
---

::: panel-tabset
## Table Preview

```{r img, echo=FALSE, fig.align='center', out.width='45%'}
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

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

data <- adae |>
  filter(
    # safety population
    SAFFL == "Y",
    # deaths
    DTHFL == "Y"
  )
```

## Build Table

```{r tbl, results = 'hide'}
tbl_dthcaus <- data |>
  tbl_hierarchical(
    variables = DTHCAUS,
    id = USUBJID,
    by = TRT01A,
    denominator = adsl,
    overall_row = TRUE,
    label = list("..ard_hierarchical_overall.." = "Death details", DTHCAUS = "**Deaths**")
  ) |>
  sort_hierarchical() |>
  modify_indent(columns = label, rows = variable == "DTHCAUS", indent = 4L)

tbl_aesdth <- data |>
  filter(AESDTH == "Y") |>
  tbl_hierarchical(
    variables = AEDECOD,
    id = USUBJID,
    by = TRT01A,
    denominator = adsl,
    overall_row = TRUE,
    label = list("..ard_hierarchical_overall.." = "Adverse events with an outcome of death", AEDECOD = "**Deaths**")
  ) |>
  sort_hierarchical() |>
  modify_indent(columns = label, rows = variable == "AEDECOD", indent = 4L)

tbl <- tbl_stack(list(tbl_dthcaus, tbl_aesdth))

tbl
```

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

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

## Build ARD

```{r ard, message=FALSE, warning=FALSE, results='hide'}
ard <- gather_ard(tbl)
ard
```

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