πŸ“¦ R Packages

Production R packages for clinical trial programming β€” RAG-powered code generation and ARS-driven TLF automation, built on the pharmaverse.
By Bhanoji Duppada Β· MIT licensed Β· pharmaverse-compatible
← Back to Portfolio
πŸ“¦ The Packages
β–Ά Live Demo
πŸ“– Help & Architecture
πŸ€– clinassist v0.1.0 Β· MIT
RAG-powered clinical TLF code generation
An R interface that turns a plain-text table shell into production-ready SAS and R code. It parses the shell, retrieves similar validated patterns from a curated CDISC corpus, and generates matching code β€” then exports CDISC ARS v1.0 metadata for full traceability.
Shell parsing

Raw shell text β†’ structured spec (TLF type, population, statistics, columns)

Dual generation

Production SAS + admiral/cards/clinify R from the same shell

Multi-scenario

Run up to 6 scenarios at once (SAF vs ITT, SAS vs R)

ARS export

CDISC ARS v1.0 JSON, compatible with siera::readARS()

ca_parse_shell()
Parse shell text into a structured spec
ca_generate_sas()
Generate production SAS code
ca_generate_r()
Generate admiral + cards R code
ca_run_scenario()
Run multiple QC scenarios
ca_export_ars()
Export CDISC ARS v1.0 JSON
ca_search()
Semantic search of shells/programs
# Shell β†’ validated SAS + R in three lines library(clinassist) spec <- ca_parse_shell("Table 14.1.1 Demographics β€” Safety Population") sas <- ca_generate_sas(spec) # production SAS r <- ca_generate_r(spec) # admiral + cards ars <- ca_export_ars(spec) # CDISC ARS v1.0 JSON
🧬 ardflow live demo · MIT
ARS-driven TLF automation in pure R
Takes a CDISC Analysis Results Standard (ARS) specification and produces a complete TLF: an Analysis Results Dataset, an FDA-style RTF, a Dataset-JSON ARD, and an HTML preview β€” all from one spec, with full spec↔result lineage for audit.
spec.R β†’ compute.R

Read ARS metadata, derive the analysis results

render.R β†’ output.R

RTF (r2rtf) + Dataset-JSON + HTML from one ARD

trace.R

Audit log linking every result cell to its spec

validate.R

Conformance checks against the ARS standard

# One ARS spec β†’ RTF + Dataset-JSON + HTML, fully traceable library(ardflow) spec <- read_ars("demographics.json") ard <- compute(spec, data = adsl) # Analysis Results Dataset render(ard, format = "rtf") # FDA-style RTF render(ard, format = "datasetjson") # CDISC Dataset-JSON ARD trace <- get_trace(ard) # spec ↔ result lineage
β–Ά See ardflow live β†’
β–Ά ardflow β€” Live real R Β· executed now
Edit the ARS spec β†’ run the real ardflow pipeline β†’ get ARD + RTF + trace
This runs actual R (dplyr + r2rtf) on the server against a synthetic ADSL dataset. Edit the CDISC ARS analysis spec below and click Run — ardflow computes the Analysis Results Dataset, renders a real submission RTF, and emits the spec→result trace. Change a method or grouping variable and watch the output change live.
πŸ”’ Synthetic ADSL data (10 subjects, 3 arms) Β· no real patients Β· runs live R 4.5 + r2rtf on the server

What problem do these packages solve?

Clinical programming has historically meant writing every TLF by hand in SAS, then independently re-programming it for QC β€” slow, repetitive, and error-prone. The industry is also shifting toward R and the CDISC Analysis Results Standard (ARS), but most teams lack tooling to bridge SAS, R, and ARS in one workflow.

These two packages close that gap: clinassist generates validated SAS+R code from a shell, and ardflow turns a machine-readable ARS spec into a complete, traceable TLF. Together they turn "write it twice, check it manually" into "specify once, generate everywhere, prove it matches."

Architecture

πŸ“‹
Shell / ARS Spec
Plain shell text or CDISC ARS JSON
πŸ”
RAG / Compute
Retrieve patterns or derive results
βš™οΈ
Generate
SAS + R code, or RTF + Dataset-JSON
βœ“
Trace / Validate
ARS export + full lineage for audit

How they fit the pharmaverse

clinassist

Built on httr2 + jsonlite. Generates code that uses admiral (ADaM derivations), cards (Analysis Results Datasets), and clinify (TLF rendering). ARS exports are compatible with siera::readARS(), so output drops straight into ARS-based pipelines.

ardflow

Pure-R package using r2rtf for submission RTF and the datasetjson standard for CDISC Dataset-JSON. Each module β€” spec, compute, render, output, trace, validate β€” is independently testable, mirroring how a regulated pipeline is built and verified.

Compliance & data

All examples and demos use synthetic, CDISC-aligned data β€” no proprietary content, no real patients, no study identifiers. The RAG corpus is built from generic CDISC-standard patterns. GDPR/HIPAA-safe by design.

Why this matters for a Clinical Data & Insights team

  • Cuts TLF development + QC time by generating both production and validation code from one spec
  • De-risks the SASβ†’R transition with a single interface producing both languages
  • Native CDISC ARS support positions the team for the standard regulators are moving toward
  • Full traceability (spec ↔ result) makes every output audit-ready
  • Packaged, tested, documented R β€” the way a tool-development function should ship internal software