Clinical Standards Hub
Non-profit Community HubNot affiliated with CDISC/SASContributions Welcome

Package Builder — Instructions

How to go from an empty scaffold to a real, installable R package — without leaving your browser.

What is the Package Builder?

It is a full R-package authoring environment that runs entirely in the browser. R itself runs locally via WebR (R compiled to WebAssembly) — there is no server-side R, nothing to install, and your code never leaves your machine to be built. You scaffold the structure, write functions with AI assistance, document and test them, validate with a real in-browser check, and export a CRAN-style source tarball or publish straight to GitHub with CI. Every project autosaves and is tied to your account, so the status checklist tracks exactly how far along each package is.

The workflow

1

Scaffold a package

Click “New package”, give it a name (letters, digits and dots; must start with a letter), an optional one-line title and description, and pick a starter template. The builder writes a valid DESCRIPTION, NAMESPACE, an example function with roxygen docs, and a test — a real package skeleton you can build on.

2

Write functions with AI

In the top box of the AI tab, describe a function in plain language. It is generated with complete roxygen2 documentation (@param, @return, @export, @examples) and dropped into its own R/ file. It is aware of the functions you already have, so names don’t collide. Review the code, then “Add to package”.

3

Generate tests with AI

The second box in the AI tab writes testthat unit tests. Name a function to target or leave it blank to test your main exported ones; the AI is grounded in your real signatures and dataset columns, so it tests what actually exists — covering the happy path plus edge cases like empty input and invalid arguments. The file lands under tests/testthat/ ready to run, replacing the placeholder hello-world test.

4

Add long-form vignettes

Every function already carries its own roxygen block. For long-form guides, the Vignette tab generates an R Markdown vignette grounded in your real functions and datasets, and automatically turns on VignetteBuilder: knitr plus the knitr/rmarkdown suggests in DESCRIPTION.

5

Generate docs & NAMESPACE

The Docs tab regenerates the man/*.Rd help pages and the NAMESPACE from the #’ @export tags in your R files. Run it after adding, renaming, or removing functions so exports and documentation stay in sync. It is deterministic — you never edit NAMESPACE by hand; any function tagged @export is exported automatically.

6

Bundle datasets

Paste or upload a CSV in the Data tab. It is stored under data-raw/, a roxygen doc stub is generated, and LazyData is enabled in DESCRIPTION. At check/export time WebR converts the CSV into a proper binary data/<name>.rda.

7

Check in your browser

The Check tab runs a subset of R CMD check entirely in your browser via WebR: syntax, package load, bundled-data integrity, roxygen/signature consistency, exported examples, and man/*.Rd validation (tools::checkRd). The full R CMD check runs in CI after you publish.

8

Export or publish

Export builds a CRAN-style source tarball (name_version.tar.gz) with freshly generated man/*.Rd, NAMESPACE and .rda data — all client-side. Publish pushes the package to a GitHub repo (README, LICENSE and a CI workflow that runs the full R CMD check). Your GitHub token can be saved encrypted for reuse.

Starter templates

Blank

DESCRIPTION, NAMESPACE and one example function — the minimal valid package.

Data analysis

Everything in Blank, plus an example bundled dataset to demonstrate data/.

Clinical helper

Adds count_pct() (n / % by group) and a small synthetic adverse-event dataset.

The status checklist

The pills across the top of each package show progress. Most are inferred automatically from your files; Check and Export flip on when you run them.

MetadataA DESCRIPTION file with a Package: field exists.
FunctionAt least one function is defined in an R/ file.
DocsAt least one roxygen block (#’) is present.
DataAt least one bundled dataset is registered.
TestsA testthat test file exists under tests/testthat/.
CheckA WebR package check has passed.
ExportThe package has been exported or published.

Reading the file tree

Files in the left pane carry small badges so you know what is yours to keep and what is just a starting point.

replaceAn example function — swap it for your own real R code.
optionalSafe to delete: tests, dataset docs, build config.
generatedman/*.Rd help pages — rebuilt from roxygen on export. Don’t hand-edit.
sample dataExample CSV under data-raw/ — replace with your own or delete.

Good to know

  • The first WebR check downloads the R runtime, so it takes a little longer; later runs are fast.
  • Edits autosave about a second after you stop typing — the header shows “Saving…” then “Saved”.
  • man/*.Rd help pages and NAMESPACE are generated from your roxygen at export — don’t edit them by hand.
  • Install an exported package locally with install.packages("name_version.tar.gz", repos = NULL, type = "source").
  • Publishing needs a GitHub token with repo-create and contents write permission (classic repo scope, or a fine-grained token with Administration + Contents: read/write).