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
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
get_cox_pairwise_df()that produce a statistics data frametbl_coxph()that render the data frame as a gtsummary tablemodify_fmt_fun(),modify_header(), pre-formatting columns,.format_pvalue()pass-through2. When to set digits / formatting at each layer
get_cox_pairwise_df()viasprintf("%.2f", ...).format_pvalue()insidetbl_coxph()modify_fmt_fun()on the gtsummary output3. Other modular components
tbl_hierarchical_rate_by_grade()+add_grade_column()— decoupled stylingtbl_roche_subgroups()+add_forest()— decoupled forest plottbl_with_pools()— pooling wrapper that works with any.tbl_fun4. Swapping layers
tbl_coxph()(e.g., from a different statistical engine).tbl_funinsidetbl_roche_subgroups()Ref: discussion in #245