insightsengineering / insightsengineering/crane

Add vignette: modular TLG pipeline (compute → tabulate → customize)

Open
#249 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
R
Stars
15
Forks
7
Avg merge
6d 9h
Merged PRs (30d)
5

Description

## Motivation

The `get_cox_pairwise_df()` → `tbl_coxph()` → `modify_*()` pattern demonstrates crane's modular design: statistics are computed separately from tabulation, and formatting can be customized at each layer. This pattern applies broadly across crane but is not documented in a user-facing way.

## Proposed vignette

A short vignette (`vignettes/modular-pipeline.Rmd`) covering:

### 1. The three layers
- **Compute** — functions like `get_cox_pairwise_df()` that produce a statistics data frame
- **Tabulate** — functions like `tbl_coxph()` that render the data frame as a gtsummary table
- **Customize** — `modify_fmt_fun()`, `modify_header()`, pre-formatting columns, `.format_pvalue()` pass-through

### 2. When to set digits / formatting at each layer
- At compute time: HR and CI precision is set by `get_cox_pairwise_df()` via `sprintf("%.2f", ...)`
- At tabulate time: p-value precision is set by `.format_pvalue()` inside `tbl_coxph()`
- After the fact: users can pre-format the p-value column as character (pass-through) or use `modify_fmt_fun()` on the gtsummary output

### 3. Other modular components
- `tbl_hierarchical_rate_by_grade()` + `add_grade_column()` — decoupled styling
- `tbl_roche_subgroups()` + `add_forest()` — decoupled forest plot
- `tbl_with_pools()` — pooling wrapper that works with any `.tbl_fun`

### 4. Swapping layers
- Bring your own data frame to `tbl_coxph()` (e.g., from a different statistical engine)
- Use a different `.tbl_fun` inside `tbl_roche_subgroups()`

Ref: discussion in #245

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.