Skip to content

R for Clinical Programmers

Learn the 20% of R that does 80% of the work in a clinical trial. From zero, or from SAS. Every program runs on real trial data, and you watch it run in DataStep Studio for R.

The 20% that matters

A small part of R does most of the daily work in a study: filter(), mutate(), joins, groups, summarise() and functions. This book teaches that part in depth, then the pharmaverse packages that the industry uses: admiral, gtsummary, rtables, xportr.

From zero, or from SAS

The text explains every idea from the start, in short plain sentences. If you know SAS, a Coming from SAS box on each idea shows the SAS form and links to the same chapter of SAS for Clinical Programmers.

Real trial data

Every example runs on the public CDISC pilot study: 254 randomised subjects, three arms, real SDTM and ADaM. You follow one subject, 01-701-1015, from SDTM to the tables.

Nothing untested

Every program on these pages ran in DataStep Studio for R before it was printed, and every output on a page is the output of that run. The numbers you read are the numbers you will get.

Part What you learn
Start here A tour of clinical R in six programs, and the setup
I · The 20% of R Data frames, the pipe, columns, groups, joins, summaries, reshaping, functions
II · ADaM ADSL, BDS (vital signs, labs), OCCDS (adverse events), ADTTE: each one by hand with dplyr, then with admiral
III · Tables, listings, figures A demographics table and an adverse event table by hand, then with gtsummary and rtables; listings, plots and delivery
IV · Quality Double programming with diffdf, and how senior programmers solve a problem
V · Advanced functions How R evaluates code, code from data, a tested function library
VI · Work like a pro DataStep Studio for R: the daily loop, the data viewer, the debugger, pry, pipeline tools

Found an error or have a question? Write to datastep.studio@gmail.com· Every program runs in DataStep Studio for R, the R extension for VS Code and Positron.

Data: the CDISC pilot study (cdiscpilot01), from the R packagespharmaversesdtm andpharmaverseadam (Apache License 2.0).

R is a project of the R Foundation. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. This book is not affiliated with or endorsed by SAS Institute Inc. or the R Foundation. CDISC, SDTM and ADaM are trademarks of the Clinical Data Interchange Standards Consortium.

© 2026 DataStep Labs. All rights reserved.