Set up R and DataStep Studio for R
You need three things: R (the language), an editor to write and run programs, and the packages that the book uses. Choose one of two ways.
| In your browser | On your computer | |
|---|---|---|
| What you install | Nothing | R, VS Code (or Positron), DataStep Studio for R, the packages |
| What you need | A free GitHub account | About 10 minutes and 2 GB of disk |
| Good for | A first look, a course, a locked work computer | Daily work |
Work in your browser: nothing to install
Section titled “Work in your browser: nothing to install”The book has a lab: a copy of every program of the book, in a ready-made computer in the cloud (a GitHub codespace). VS Code opens in your browser with R, every package, DataStep Studio for R and the programs ready.
-
Open the lab: github.com/datastep-labs/r-for-clinical-programmers.
-
Click Open in GitHub Codespaces and sign in to GitHub. A free account is enough.
-
Wait a few minutes the first time. VS Code opens in your browser with the file
START-HERE.md: a short lab that walks you through the tools.
A free GitHub account includes a monthly amount of codespace time. Without a payment method, you are never charged. Stop the codespace when you are done, and it keeps your files for the next time.
On your own computer
Section titled “On your own computer”-
Install R. Download R 4.4 or later for your system from cloud.r-project.org and install it with the standard choices.
-
Install an editor. Install VS Code or Positron, the data science editor of Posit. Both are free. This book shows VS Code. Everything works the same in Positron.
-
Install DataStep Studio for R. In VS Code, open the Extensions view (the four squares on the left), search for DataStep Studio for R, and click Install. Or type this in a terminal:
Terminal window code --install-extension datastep-labs.datastep-rIn Positron, download the
.vsixfile from the Marketplace page (Download Extension), then use Extensions: Install from VSIX…. -
Get the programs. Download the lab as a ZIP file (on the lab page: Code, then Download ZIP), unpack it, and open the folder in your editor: File, Open Folder.
-
Install the packages. The folder has a file
renv.lock: the list of every package of the book, with its exact version. Open a terminal in the editor (Terminal, New Terminal) and type:Terminal window Rscript -e 'renv::restore(prompt = FALSE)'The folder installs the package
renvby itself the first time R starts there. The restore takes a few minutes. The packages go into the folder of the project, not into your main R library. -
Check the setup. Open the command palette (
Ctrl+Shift+P, on a MacCmd+Shift+P), type DataStep R: Check Setup, and press Enter. Each line says PASS, FIX or NOTE. A line with FIX has the command that repairs it.
Your first run
Section titled “Your first run”Open programs/01_1_first.R and press F4. F4 runs the selected lines. With nothing selected, it runs the whole file. The first time, DataStep Studio for R starts an R session for the project. The R Console panel shows what the program printed, and a verdict:
# A tibble: 4 × 2 ARM n <chr> <int> 1 Placebo 86 2 Screen Failure 52 3 Xanomeline High Dose 84 4 Xanomeline Low Dose 84RESULT: CLEAN (0.03 s)RESULT: CLEAN means that the program ran with no error and no warning. You will see two other verdicts: CHECK (it ran, but a message needs your attention) and ERROR (it stopped). Chapter 20 explains them.
Now press F12. The data viewer opens the last data frame that the program made. You can sort, filter and search it without code (chapter 21).
The study data
Section titled “The study data”The book uses the CDISC pilot study (cdiscpilot01) from two packages of the pharmaverse, a group of open-source R packages for clinical reporting:
| Package | What it has | Example |
|---|---|---|
pharmaversesdtm |
the SDTM domains | pharmaversesdtm::dm (306 subjects), pharmaversesdtm::ae (1191 adverse events) |
pharmaverseadam |
reference ADaM data sets, made with the package admiral |
pharmaverseadam::adsl, pharmaverseadam::adae |
You build your own ADaM data sets in Part II and compare them with these.
The editions
Section titled “The editions”The run keys, the log and the data viewer are in the free Community edition. The debugger, pry, the pipeline tools and the checks of Part VI are in the Professional edition. All Professional features are free of charge during Early Access, until 17 February 2027. The Community features stay free.
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.