How I Structured My Project

A big-picture overview of the SSC code

Published

March 13, 2026

This post gives a high-level overview of how the entire SSC project is organised.
The project uses a simple but robust structure:

Directory Structure

R/
├── init.R
├── main.R
├── comparison/
│   ├── comp_bin_fixed_exact.R
│   ├── comp_bin_fixed_pooled.R
│   ├── comp_bin_gs.R
│   ├── comp_bin_one_arm_exact.R
│   ├── comp_bin_one_arm.R
│   ├── comp_surv_fixed.R
│   ├── comp_surv_gs.R
│   └── comp_surv_one_arm.R
├── functions/
│   ├── checks.R
│   ├── e_ratio.R
│   ├── evaluate_relevancy.R
│   ├── helpers.R
│   ├── n_ratio.R
│   └── exact_wrapper.R
├── S7/
│   ├── generics.R
│   ├── ssc_design.R
│   └── ssc_results.R
├── side-analysis/
│   ├── bin2arms_exact.R
│   └── lakatos_n_lan.R
└── wrappers/
    ├── ahern_wrapper.R
    ├── bbssr_wrapper.R
    ├── exact_wrapper.R
    ├── gsdesign2_wrapper.R
    ├── oa2s_wrapper.R
    ├── rashnu_wrapper.R
    ├── rpact_wrapper.R
    └── sssas_wrapper.R

main.R: the entry point

main.R is the orchestrator of the entire project.
Running this file executes all steps in the predefined order:

  • initialization,
  • survival comparisons,
  • binary comparisons,
  • result combination,
  • exporting final outputs.

This is described in detail in the post:
➡️ “My main pipeline”

init.R: preparing the environment

init.R configures everything needed for the project:

  • loads all required packages,
  • creates global objects (e.g. ssc, wrapper, error rate),
  • sources helper functions,
  • loads all wrapper functions,
  • loads S7 classes and methods.

Comparison scripts (comp_*.R)

Each script corresponds to one design × one endpoint and follows the same structure:

  1. build parameter grid
  2. create a ssc_design object
  3. compute results using wrappers
  4. validate with S7
  5. combine results
  6. compute derived metrics (N‑ratio, relevancy)
  7. generate tables & plots
  8. export everything inside the ssc object

This standard pattern is what makes the pipeline extensible: adding a new design simply means adding a new comp_xyz.R following the same recipe.

functions/ and wrappers/ directories

These directories contains all reusable building blocks of the project:

Core helpers

  • checks.R — input validation
  • helpers.R — general utilities
  • evaluate_relevancy.R — rule defining “high / medium / low” relevancy
  • n_ratio.R — N‑Ratio computation

Wrappers for external R packages

  • rpact_wrapper.R
  • bbssr_wrapper.R
  • gsdesign2_wrapper.R
  • rashnu_wrapper.R
  • ahern_wrapper.R
  • exact_2_arms.R — exact binomial implementation
  • sssas_wrapper.R
  • oa2s_wrapper.R

This part is discussed in detail in the post:
➡️ “Clean Wrapper Functions for Sample Size Calculations”

The S7 layer (S7/)

This folder contains a minimal but powerful object system for the project:

  • ssc_design.R — defines how a design is represented
  • ssc_results.R — defines how results are stored & validated
  • generics.R — shared S7 methods (print, summary, extractors, etc.)

This is discussed in detail in the post:
➡️ “S7 Classes for Designs and Results”