How I Structured My Project
A big-picture overview of the SSC code
This post gives a high-level overview of how the entire SSC project is organised.
The project uses a simple but robust structure:
- a central
main.Rfile, from which the full pipeline is executed;
- modular comparison scripts, one per design;
- dedicated
functions/andwrappers/directory for all helpers and wrappers;
- a small S7 layer holding the two core classes (
ssc_designandssc_results).
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.Rmain.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:
- build parameter grid
- create a
ssc_designobject - compute results using wrappers
- validate with S7
- combine results
- compute derived metrics (N‑ratio, relevancy)
- generate tables & plots
- export everything inside the
sscobject
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 validationhelpers.R— general utilitiesevaluate_relevancy.R— rule defining “high / medium / low” relevancyn_ratio.R— N‑Ratio computation
Wrappers for external R packages
rpact_wrapper.Rbbssr_wrapper.Rgsdesign2_wrapper.Rrashnu_wrapper.Rahern_wrapper.Rexact_2_arms.R— exact binomial implementationsssas_wrapper.Roa2s_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 representedssc_results.R— defines how results are stored & validatedgenerics.R— shared S7 methods (print, summary, extractors, etc.)
This is discussed in detail in the post:
➡️ “S7 Classes for Designs and Results”