A low-stakes sandbox for practising the GitHub workflow — fork, clone, branch, commit, push, pull request — while running a small piece of real R code against pharmaverse source data.
Nothing here is graded and nothing you do can break anything. Make a mess, delete your fork, start again. That is the point.
This repo is the hands-on companion to the Pharmaverse Onboarding site. If you have not set up R and a GitHub account yet, start with Getting Started.
- Fork this repo to your own GitHub account.
- Open your fork in Posit Cloud — the same browser-based RStudio the pharmaverse examples site assumes. Nothing to install.
- Branch, then run
R/explore_dm.Rand confirm you see output. - Edit the
YOUR TURNsection of the script so it answers one more question about the data. - Commit and push your change to your fork.
- Open a pull request back to this repo.
Steps 5 and 6 are the part worth practising. The R code is deliberately tiny.
Click Fork (top-right of this page on GitHub) and create the fork under your
own account. You now have https://github.com/YOUR-USERNAME/pharmaverse-practice.
Posit Cloud runs RStudio in your browser — no local install, and the same environment this guide recommends in Getting Started, Step 1.
- Sign in at posit.cloud
- New Project → New Project from Git Repository
- Paste your fork's URL:
https://github.com/YOUR-USERNAME/pharmaverse-practice.git - Click OK. Posit Cloud clones your fork and opens it in RStudio.
Check that the URL has your username in it, not
jeffreyad. You can only push to your own fork.
Coming from SAS: cloning is like copying a study area from a shared drive to your own working directory — except Git remembers where it came from and every change you make along the way.
Prefer to work locally instead?
You need Git for Windows (or Git on macOS / Linux) plus RStudio Desktop. GitHub Desktop is optional, is not supported on Windows Server, and is not needed for this repo. Then, in a terminal or the RStudio Terminal tab:
git clone https://github.com/YOUR-USERNAME/pharmaverse-practice.git
cd pharmaverse-practiceThe rest of the steps below are the same; use the RStudio Git pane either way.
To push from Posit Cloud you need a Personal Access Token (PAT) — GitHub does not accept an account password. In the RStudio Console:
usethis::create_github_token() # opens GitHub in a new tab — generate, then copy the token gitcreds::gitcreds_set() # paste the token when prompted
{usethis} is already installed on Posit Cloud's default image. If Posit Cloud
asks for your GitHub username and password on a later push, run
gitcreds::gitcreds_set() again and paste the same token as the password.
Never work directly on main. In the RStudio Git pane (top-right), click the
New Branch button, name it for what you are doing — e.g.
explore-sex-distribution — and click Create.
Terminal equivalent
git checkout -b explore-sex-distribution
In the RStudio Console:
source("install_packages.R")This installs {pharmaversesdtm}
(CDISC pilot SDTM data, straight from CRAN — no download to manage) and
{dplyr}.
source("R/explore_dm.R")You should see two small tables printed: subject counts by treatment arm, and an age summary by arm. If you do, your environment works.
Open R/explore_dm.R and find the block marked:
# ============================ YOUR TURN ============================Follow the instructions there. It asks you to add one short dplyr summary of
the dm data. There is no single right answer.
In the Git pane: tick the checkbox next to R/explore_dm.R, click Commit,
type a message, and click Commit again.
Add sex distribution summary by treatment arm
Say what you did and why — not "changes" or "update".
In the Git pane, click the green Push (up-arrow) button. Enter your GitHub username and paste your PAT as the password if prompted.
Go to your fork on GitHub. It will show a Compare & pull request button. Click it, write a sentence about what you changed, and submit. Done — that is a complete contribution loop.
You do not need this PR to be merged. Submitting it is the practice.
{pharmaversesdtm} bundles the
CDISC pilot SDTM datasets — dm, ae, vs, lb, ex, and more — as ordinary
R data frames. This repo uses dm (Demographics), the SDTM domain most SAS
programmers already know cold.
library(pharmaversesdtm) data("dm") ?dm # variable-level help
| Symptom | Fix |
|---|---|
there is no package called 'pharmaversesdtm' |
Run source("install_packages.R") |
could not find function "%>%" or ` |
>` errors |
| Push rejected, or GitHub keeps asking for a password | Your PAT is not set. Run gitcreds::gitcreds_set() and paste the token (step 3). Background: Happy Git, ch. 9 |
| No Git pane in Posit Cloud | The project was not created from Git. Delete it and redo step 2 with New Project from Git Repository |
| Pushed to the wrong place | You used this repo's URL instead of your fork's. Redo step 2 with github.com/YOUR-USERNAME/... |
Code is released under the MIT License. The pilot SDTM data is
distributed by CDISC via {pharmaversesdtm} under that package's own terms.