flowchart LR
RAW["**Raw Data** {pharmaverseraw}"]
SDTM["**SDTM** {sdtm.oak}"]
ADAM["**ADaM** {admiral}"]
TLG["**TLG** {rtables} · {tern}"]
INT["**Interactive** {teal}"]
DOC["**Documents** {autoslideR}"]
ESUB["**eSub**"]
LOG["**Logging**"]
RAW --> SDTM --> ADAM --> TLG
TLG <--> INT
TLG --> DOC
TLG --> ESUB
RAW -..-> LOG
SDTM -..-> LOG
ADAM -..-> LOG
TLG -..-> LOG
style RAW fill:#d6eaf8,stroke:#2e86c1,color:#000
style SDTM fill:#2e86c1,stroke:#1a5276,color:#fff
style ADAM fill:#2e86c1,stroke:#1a5276,color:#fff
style TLG fill:#2e86c1,stroke:#1a5276,color:#fff
style INT fill:#d5f5e3,stroke:#1e8449,color:#000
style DOC fill:#d5f5e3,stroke:#1e8449,color:#000
style ESUB fill:#d5f5e3,stroke:#1e8449,color:#000
style LOG fill:#fdebd0,stroke:#ca6f1e,color:#000
pharmaverse examples
The true beauty of pharmaverse (and open source in general) is when efforts from various different developers come together to complement each other as a whole greater than the sum of the individual parts. By design in R, no single package will ever completely cover all your needs, but by piecing them together we can make complex tasks increasingly simple.
This book contains end-to-end examples of using pharmaverse packages together to achieve common clinical reporting analyses, such as SDTM, ADaM, and Tables/Listings/Graphs. The examples use consistent source test raw datasets from {pharmaverseraw}, SDTMs from {pharmaversesdtm}, and ADaMs from {pharmaverseadam} respectively.
We’ll endeavour to include a selection of examples here over time, e.g. to help users when trying out the packages for PK/PD or Therapeutic Area specific (such as Oncology or Vaccines) analyses.
Note that this examples book should only be used to show how collections of packages can be used in conjunction - more thorough examples of individual package usages would always be covered in the package site vignettes and no need to repeat here.
Running the examples
Posit Cloud
Launch Posit Cloud to run any example interactively without a local R installation. Each example can be explored via a live and interactive Posit Cloud environment (preconfigured with all required package installations).
You can do this by clicking File → Open File and then choosing whichever example script, e.g. adam/adsl.R. Feel free to try out customizing any of the examples to better fit any of your own internal clinical reporting workflows!
Locally
To run examples locally, download the repository and run the following in the R console inside the project folder to install dependencies:
Note: the R scripts are generated from .qmd files automatically using knitr::purl.
Getting Started
The examples are organized by the stage of the clinical data pipeline they cover. If you’re new to pharmaverse, working through them in order gives a natural end-to-end view of how the ecosystem fits together.
| Section | What it covers | Good starting point if… |
|---|---|---|
| SDTM | Converting raw collected data to CDISC SDTM domains | You work upstream of ADaM or want to understand the data origin |
| ADaM | Building analysis datasets (ADSL, ADTTE, ADPC, etc.) from SDTM |
You’re implementing analysis-ready datasets for reporting |
| TLG | Creating tables, listings, and graphs for clinical study reports | You focus on outputs — demographics, AEs, survival, PK summaries |
The site also includes introductory examples for several additional workflow areas:
- Interactive — building clinical data exploration apps with
{teal} - Documents — automated report generation from ADaM data
- Logging — logging and traceability for clinical R workflows
- eSub — preparing outputs for electronic regulatory submission
Packages Used in These Examples
The table below covers every package used across the examples site, grouped by the part of the pipeline where it appears. Clicking a package name opens its documentation; the Example column links to where it is used on this site.
Data Packages
| Package | Description | Example |
|---|---|---|
{pharmaverseraw} |
Source raw datasets (AE, DM, EX, DS domains) used as the starting point for all SDTM examples |
SDTM |
{sdtm.oak} |
SDTM programming in R — maps raw collected data to CDISC SDTM domains using an algorithm-based engine | SDTM |
{pharmaversesdtm} |
CDISC SDTM example datasets generated from {pharmaverseraw} |
SDTM / ADaM |
{pharmaverseadam} |
CDISC ADaM example datasets (ADSL, ADTTE, ADPC, etc.) used across TLG and PK examples |
TLG / PK |
ADaM Packages
| Package | Description | Example |
|---|---|---|
{admiral} |
ADaM dataset construction in R — the core package for building ADSL, ADAE, ADTTE, and other standard domains |
ADaM |
{admiralonco} |
Oncology-specific ADaM extensions for {admiral} — adds functions for tumor response, DOR, and TTE oncology endpoints |
ADaM |
{metacore} |
Stores and validates dataset metadata (variable definitions, codelists) from specs in a consistent R object | ADaM |
{metatools} |
Utilities for working with {metacore} objects — checking variables, applying codelists, and deriving variables from metadata |
ADaM |
{xportr} |
Applies SAS XPT metadata (types, labels, lengths, formats) and exports submission-ready .xpt transport files |
ADaM |
TLG Packages
| Package | Description | Example |
|---|---|---|
{rtables} |
Framework for building complex nested tables with flexible layouts — the foundation of the NEST TLG stack | Demographics / AE / PK |
{tern} |
Analysis functions for clinical trial TLGs built on {rtables} — covers demographics, AEs, survival, PK summaries |
Demographics / AE / PK |
{rlistings} |
Creates regulatory-ready listings from ADaM datasets | PK |
{gtsummary} |
Publication-ready summary and analytical tables — ideal for demographics and analysis summaries | Demographics |
{ggsurvfit} |
Publication-ready Kaplan-Meier and time-to-event figures built on {ggplot2} |
TLG |
{cards} |
Creates Analysis Results Datasets (ARDs) following the emerging CDISC Analysis Results Standard | Demographics / AE |
{tfrmt} |
Transforms ARDs into publication-ready tables with precise formatting control — particularly suited to RTF regulatory outputs | Demographics / AE |
Interactive Packages
| Package | Description | Example |
|---|---|---|
{teal} |
Shiny-based framework for building interactive clinical trial data exploration apps — supports filter panels, reproducibility code, and a reporter for exporting results | Interactive |
Have an example that others would benefit from? Open an issue with your idea — new issues are automatically added to our project board for the team to review and prioritize. If you’re willing to contribute the code yourself, say so in the issue and the team will provide repo access.
A note on dependencies: there is no renv here. If your example needs a new package, add it to Imports in the root DESCRIPTION file and the deployment pipeline will install the latest CRAN release automatically.
You can see a list of current contributors via our GitHub repo DESCRIPTION file. If ever unsure, tag the team in your issue using @pharmaverse/examples.
Consider giving the Examples repo and any of the package repos listed in the tables above a ⭐ GitHub star — it helps maintainers demonstrate community adoption and keeps the ecosystem visible to new users.