| Type: | Package |
| Title: | FDA Safety Tables and Figures |
| Version: | 0.2.0 |
| Date: | 2026-07-09 |
| Description: | Provides implementations of safety tables and figures recommended by the FDA (U.S. Food and Drug Administration) for clinical trial reporting. Functions generate standard outputs for adverse events, laboratory abnormalities, vital signs, exposure, and other safety domains following the FDA's Safety Reporting guidelines. Outputs are built on the 'gtsummary', 'cards', and 'cardx' frameworks, enabling reproducible and submission-ready clinical trial safety summaries. |
| License: | Apache License (≥ 2) |
| URL: | https://github.com/pharmaverse/cardinal/, https://pharmaverse.github.io/cardinal/ |
| BugReports: | https://github.com/pharmaverse/cardinal/issues |
| Depends: | R (≥ 4.2), cards (≥ 0.8.1), cardx (≥ 0.3.4), gtsummary (≥ 2.5.1) |
| Imports: | dplyr (≥ 1.2.1) |
| Suggests: | cowplot (≥ 1.2.0), crane (≥ 0.3.1), forcats (≥ 1.0.1), ggplot2 (≥ 4.0), ggsurvfit (≥ 1.2.0), gt (≥ 1.3.0), knitr (≥ 1.50), labelled (≥ 2.16.0), lubridate (≥ 1.9), pharmaverseadam (≥ 1.3.0), purrr (≥ 1.2), random.cdisc.data (≥ 0.3.16), rlang (≥ 1.1.7), rtables (≥ 0.6.11), tern (≥ 0.9.8), svglite (≥ 2.2.2), testthat (≥ 3.3.1), tidyr (≥ 1.3.1), withr (≥ 3.0.2) |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| RoxygenNote: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-24 08:50:51 UTC; zhus31 |
| Author: | Pawel Rucki [ctb],
Abinaya Yogasekaram
|
| Maintainer: | Joe Zhu <joe.zhu@roche.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-04 09:50:02 UTC |
cardinalfda
Description
Implementation of FDA Safety Tables and Figures
Author(s)
Maintainer: Joe Zhu joe.zhu@roche.com (ORCID)
Authors:
Abinaya Yogasekaram ayogasek@gmail.com (ORCID)
Emily de la Rua emilydelarua@gmail.com (ORCID)
Vincent Shen
Other contributors:
Pawel Rucki pawel.rucki@roche.com [contributor]
Daniel D. Sjoberg danield.sjoberg@gmail.com (ORCID) [contributor]
Benoit Falquet benoit.falquet@roche.com (ORCID) [contributor]
Lluís Revilla Sancho lluis.revilla_sancho@roche.com (ORCID) [contributor]
Huan Lu huan.lu@sanofi.com [contributor]
Alex Assuied [contributor]
Yoshito Koujin [contributor]
Korbinian Matthias [contributor]
Jessica Knizia [contributor]
Freeman Wang [contributor]
See Also
Useful links:
Report bugs at https://github.com/pharmaverse/cardinal/issues
Pre-Process alt_counts_df for Safety Population
Description
If alt_counts_df is not NULL, will check for required variables (arm_var) and filter
to include only safety population (saffl_var, if specified), then apply tern::df_explicit_na().
Usage
alt_counts_df_preproc(
alt_counts_df,
id_var = "USUBJID",
arm_var = "ARM",
saffl_var = NULL
)
Arguments
alt_counts_df |
( |
id_var |
( |
arm_var |
( |
saffl_var |
( |
Value
A data.frame (modified alt_counts_df) or NULL.
Standard Arguments
Description
This documentation lists all the arguments in cardinal that are used repeatedly by functions to output tables.
Arguments
show_colcounts |
( |
arm_var |
( |
id_var |
( |
saffl_var |
( |
ser_var |
( |
lbl_overall |
( |
vars |
( |
lbl_vars |
( |
pref_var |
( |
soc_var |
( |
lbl_pref_var |
( |
lbl_soc_var |
( |
.stats |
( |
.formats |
(named |
na_rm |
( |
prune_0 |
( |
na_level |
( |
adae |
( |
adex |
( |
advs |
( |
adsl |
( |
alt_counts_df |
( |
annotations |
(named |
ard |
( |
denominator |
( |
df |
( |
eosdy_var |
( |
fmqsc_var |
( |
fmqnam_var |
( |
fmq_scope |
( |
ggtheme |
( |
return_ard |
( |
risk_diff |
(named
|
sex_scope |
( |
table_engine |
( |
trtedtm_var |
( |
trtemfl_var |
( |
trtsdtm_var |
( |
u_trtdur |
( |
xticks |
( |
x_lab |
( |
yticks |
( |
y_lab |
( |
Check Values of Flag Variables
Description
Flag variables are expected to take one of two values: "Y" (yes/true) or
"N" (no/false). Missing values are also accepted and treated as "N".
Usage
assert_flag_variables(df, flag_vars, na_level = "<Missing>")
Arguments
df |
( |
flag_vars |
( |
na_level |
( |
Value
Invisibly returns TRUE if all flag variables are valid; otherwise stops with an error.
Initialize Table Layout with Annotations
Description
Initializes a table layout via rtables::basic_table() and applies show_colcounts
argument. Adds any annotations supplied via the annotations argument.
Usage
basic_table_annot(show_colcounts = TRUE, annotations = NULL)
Arguments
show_colcounts |
( |
annotations |
(named |
Value
An rtables PreDataTableLayouts object suitable for passing to further layout functions, and
to build_table.
FDA Table 2: Baseline Demographic and Clinical Characteristics, Safety Population, Pooled Analyses
Description
Creates FDA Table 2 showing baseline demographic and clinical characteristics for the safety population.
Usage
make_table_02(
df,
return_ard = TRUE,
arm_var = "TRT01A",
saffl_var = "SAFFL",
vars = c("SEX", "AGE", "AGEGR1", "ETHNIC", "RACE"),
label = list()
)
Arguments
df |
( |
return_ard |
( |
arm_var |
( |
saffl_var |
( |
vars |
( |
label |
(named |
Details
-
dfmust contain the variables specified byarm_var,saffl_var, and all variables invars. Rows with
saffl_var != "Y"are excluded from the table (safety population filter applied internally).Data-specific preprocessing (e.g. joining additional variables, deriving new columns) should be performed by the caller before passing
dfto this function.Continuous variables are summarised with mean (SD) and median (min, max).
Categorical variables are summarised with n (%).
When
return_ard = TRUE, returns a named list with elementstable(agtsummaryobject) andard(the intermediate ARD); otherwise returns thegtsummarytable directly.
Value
A gtsummary table, or if return_ard = TRUE, a named list with elements table and ard.
Examples
library(dplyr)
adsl <- pharmaverseadam::adsl |>
filter(TRT01A != "Screen Failure")
result <- make_table_02(df = adsl)
result$table
Split Columns by Arm Variable
Description
Splits rtables layout into columns by arm variable. Appends an "overall" column as the
rightmost column if lbl_overall is supplied.
Usage
split_cols_by_arm(lyt, arm_var = "ARM", lbl_overall = NULL, risk_diff = NULL)
Arguments
lyt |
( |
arm_var |
( |
lbl_overall |
( |
risk_diff |
(named
|
Value
An rtables PreDataTableLayouts object suitable for passing to further layout functions, and
to build_table.