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

FDA Table 13

Patients With Common Adverse Events Occurring at >=XX% Frequency, Safety Population, Pooled Analyses

table
FDA
safety
adverse event
  • 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"
  )
Code
tbl <- tbl_hierarchical(
  data,
  variables = c(AEDECOD),
  by = TRT01A,
  id = USUBJID,
  denominator = adsl,
  overall_row = FALSE
) %>%
  # filter with >=5% Frequency
  filter_hierarchical(sum(n) / sum(N) >= 0.05) %>%
  modify_header(label = "Preferred Term") %>%
  remove_footnote_header(columns = everything())

tbl

Code
ard <- gather_ard(tbl)
ard
$tbl_hierarchical
{cards} data frame: 99 x 13
   group1 group1_level variable variable_level   context stat_name stat_label  stat stat_fmt fmt_fun warning error gts_column
1    <NA>                TRT01A      A: Drug X categori…         n          n   134      134       0                   stat_1
2    <NA>                TRT01A      A: Drug X categori…         N          N   400      400       0                   stat_1
3    <NA>                TRT01A      A: Drug X categori…         p          % 0.335     33.5    <fn>                   stat_1
4    <NA>                TRT01A      B: Place… categori…         n          n   134      134       0                   stat_2
5    <NA>                TRT01A      B: Place… categori…         N          N   400      400       0                   stat_2
6    <NA>                TRT01A      B: Place… categori…         p          % 0.335     33.5    <fn>                   stat_2
7    <NA>                TRT01A      C: Combi… categori…         n          n   132      132       0                   stat_3
8    <NA>                TRT01A      C: Combi… categori…         N          N   400      400       0                   stat_3
9    <NA>                TRT01A      C: Combi… categori…         p          %  0.33     33.0    <fn>                   stat_3
10 TRT01A    A: Drug X  AEDECOD      dcd A.1.… hierarch…         n          n    50       50    <fn>                   stat_1
ℹ 89 more rows
ℹ Use `print(n = ...)` to see more rows
Source Code
---
title: FDA Table 13
subtitle: Patients With Common Adverse Events Occurring at >=XX% Frequency, Safety Population, Pooled Analyses
categories: [table, FDA, safety, adverse event]
---

::: 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)

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"
  )
```


## Build Table

```{r tbl, results = 'hide'}
tbl <- tbl_hierarchical(
  data,
  variables = c(AEDECOD),
  by = TRT01A,
  id = USUBJID,
  denominator = adsl,
  overall_row = FALSE
) %>%
  # filter with >=5% Frequency
  filter_hierarchical(sum(n) / sum(N) >= 0.05) %>%
  modify_header(label = "Preferred Term") %>%
  remove_footnote_header(columns = everything())

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='60%'}
```

## Build ARD

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

```{r, echo=FALSE}
# Print full 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