r4subcore

r4subcore is the foundational package in the R4SUB ecosystem. It defines the core data contracts, parsers, evidence schema, and scoring primitives needed to quantify clinical submission readiness.

It is intentionally “boring and stable”: other R4SUB packages (e.g., r4subtrace, r4subrisk, r4subscore) build on these structures and interfaces.


Why r4subcore?

Clinical submission readiness is rarely a single tool output. It’s an evidence graph across:

r4subcore provides: 1. A standardized Evidence Table schema 2. Common parsers to ingest heterogeneous sources 3. A consistent indicator / signal abstraction 4. Scoring primitives (normalize, weight, calibrate, aggregate) 5. A reproducible run context (run_id, dataset_id, study_id, tool version)


Package scope

In scope

Out of scope


Installation

Development install

# install.packages("pak")
pak::pak("R4SUB/r4subcore")

Requirements


Core concepts

1) Evidence Table (the heart of R4SUB)

All inputs are normalized into a single tabular contract: an evidence dataset. This enables scoring, drilldown, traceability, and reporting.

Minimum columns (v0.1):

column type meaning
run_id chr unique ID for a run
study_id chr study identifier
asset_type chr dataset, define, program, validation, spec, etc.
asset_id chr unique ID of the asset (e.g., ADSL, define.xml)
source_name chr tool/source name (e.g., pinnacle21)
source_version chr tool version
indicator_id chr the signal definition identifier
indicator_name chr human name
indicator_domain chr quality, trace, risk, usability
severity chr info, low, medium, high, critical
result chr pass, fail, warn, na
metric_value dbl numeric value (if applicable)
metric_unit chr unit for metric
message chr short description
location chr pointer (dataset/variable/rule line)
evidence_payload json raw structured payload
created_at POSIXct ingestion timestamp

Guarantees:

Use:


2) Indicators (signals)

An indicator is a definition of what to measure, not necessarily how to calculate it.

Indicators have:

r4subcore provides:

Other packages implement the actual calculations and output evidence rows using these IDs.


3) Scoring primitives (transparent & composable)

r4subcore includes small, auditable functions for:

SCI itself is not in this package.


Quick start

Create a run context

library(r4subcore)

ctx <- r4sub_run_context(
  study_id = "ABC123",
  environment = "DEV",
  user = Sys.info()[["user"]]
)
ctx$run_id

Ingest validation results (example)

raw <- read.csv("p21_report.csv")

ev <- p21_to_evidence(
  raw,
  ctx = ctx,
  asset_type = "validation",
  source_version = "P21-3.0"
)

validate_evidence(ev)

Summarize evidence quickly

evidence_summary(ev)

Architecture

Main modules

Extensibility


Design principles


Roadmap

v0.1

v0.2


Contributing


License

MIT – see LICENSE file.