R Engineering Playbook

From R development to R engineering

NoteNew here? Start with a series

Foundations: fourteen posts on the practices around R code, in reading order. Then Testing (testthat to shinytest2) and Pharma (clinical reporting with R).

NoteFeeds

Follow everything with the full feed, or only one kind of post: R, Shiny and R packages (R is the subject or the tool), AI and agentic coding (not tied to R), or software engineering practices (Git, CI/CD, security, releases).

package-dev · part 3

Dependencies: DESCRIPTION and NAMESPACE

Declare external packages in DESCRIPTION Imports and Suggests, call functions through pkg::fun() or @importFrom, and guard optional dependencies cleanly.

2026-09-29 11 min
package-dev · part 4

Documenting functions with roxygen2

Generate man/*.Rd documentation and NAMESPACE exports directly from inline roxygen2 blocks, and keep examples executable in R CMD check.

2026-09-29 11 min
package-dev · part 1

From scripts to a package

Move reusable analysis helpers from sourced scripts into a minimal R package, and replace workspace pollution with the devtools::load_all() loop.

2026-09-29 10 min
foundations · part 15

Companion code: show it, link it, test it

How to ship runnable companion scripts in Quarto docs: the include shortcode pattern, path rules, and CI checks that catch unlinked files.

2026-09-27 9 min
testing · part 7

Coverage and tests as evidence

Use covr to spot untested paths, export Cobertura and JUnit XML in CI, and build automated requirement traceability matrices.

2026-09-27 9 min
foundations · part 16

It worked locally: two hosting bugs every check missed

A static Quarto site passed every local link and render test, but failed in a PR preview: how trailing slashes and unconfigured MIME types break hosted assets.

2026-09-27 10 min
pharma · part 6

QC and double programming with {diffdf}

Why independent programming exists in clinical reporting, how risk-based QC structures verification tiers, and how to reconcile datasets and results in R with diffdf.

2026-09-27 12 min
pharma · part 7

R in regulatory submissions and {pkglite}

What the R Consortium R submission pilots to the FDA tested, and how {pkglite} packs R packages into plain text that an eCTD submission can carry.

2026-09-27 9 min
pharma · part 5

Validation-ready R packages

How to evaluate open-source R packages for GxP clinical reporting using the R Validation Hub risk-based framework, riskmetric, and documented evidence.

2026-09-27 9 min
foundations · part 5

CI with GitHub Actions

Run R CMD check, tests, and link validation automatically on clean GitHub Actions runners with pinned dependencies.

2026-09-26 5 min

Catch broken links before your readers do

Validate internal links across rendered documentation in CI using offline link scanners to block broken references before release.

2026-09-26 6 min
foundations · part 3

Conventional commits & PR title checks

Structure commit messages and PR titles to automate changelogs and trace changes back to requirements.

2026-09-26 5 min
testing · part 5

End-to-end Shiny tests with shinytest2

Drive Shiny applications end to end with shinytest2 and headless Chrome, testing real browser rendering, user input sequences, and reactive outputs.

2026-09-26 11 min
pharma · part 2

Generating tables, figures and listings in R

How to engineer clinical TFLs in R across direct layout engines and ARD-first architectures, with RTF export, listings, and team conventions.

2026-09-26 10 min
foundations · part 14

Handoffs & agentic context

Provide AI coding agents with durable project instructions and concise handoffs instead of endless chat history.

2026-09-26 9 min
foundations · part 1

Identity & environment isolation

Isolate git identities, SSH keys, and environment variables across personal, work, and client projects on one machine.

2026-09-26 9 min
foundations · part 4

Pre-commit hooks, formatting & linting

Catch syntax errors, stale documentation, and styling differences automatically before code reaches review.

2026-09-26 3 min
testing · part 6

Property-based testing in R

Define general invariants, generate varied test inputs with quickcheck, and use shrinking to pinpoint edge cases in R functions and clinical derivations.

2026-09-26 9 min
foundations · part 9

Releases & changelogs

Adopt semantic versioning, readable changelogs, and annotated git tags to support change control.

2026-09-26 4 min
foundations · part 13

Repo hygiene files

Use standard repository hygiene files like README, LICENSE, and CONTRIBUTING to answer questions before they are asked.

2026-09-26 4 min
foundations · part 6

Secret scanning with gitleaks

Scan commits and history for accidental credentials before code leaves your machine and on CI.

2026-09-26 6 min
foundations · part 7

Secrets management

Separate configuration names in version control from secrets stored in vaults and environment variables.

2026-09-26 4 min
testing · part 3

Snapshot tests for R output, tables and plots

Capture complex console output, rtables layouts, and plots with testthat snapshots and vdiffr to catch regressions without fragile manual assertions.

2026-09-26 13 min
testing · part 2

Test design: fixtures, temporary state and mocking

Isolate test state with withr, manage fixtures cleanly in testthat 3e, and mock boundary functions to build repeatable verification suites.

2026-09-26 9 min
foundations · part 11

Test your guardrails: probe PRs

Challenge CI checks and pre-commit hooks deliberately with failing test PRs to prove guardrails work.

2026-09-26 4 min
testing · part 4

Testing Shiny server logic with testServer()

Test Shiny modules and server logic headless with shiny::testServer(), verify reactive state and return values, and separate pure logic for testthat.

2026-09-26 10 min
pharma · part 4

The CDISC Analysis Results Standard and {siera}

How the CDISC Analysis Results Standard models clinical analyses as data, and how siera ingests ARS metadata to generate auditable R reporting scripts.

2026-09-26 11 min
pharma · part 1

The clinical reporting pipeline in R

Which R packages cover each stage of clinical reporting, from raw data to SDTM, ADaM, TFLs and submission files, and how the stages connect.

2026-09-26 9 min
testing · part 1

testthat essentials

Set up testthat 3rd edition, structure unit tests with expectations, run them locally and in CI, and build reproducible verification suites.

2026-09-26 7 min
No matching items