Repository navigation
Tabulate SUMMARISE clause - #622
Conversation
setup_rows renumbers a separated facet's multi-rank group keys to single ids right after the reorder, so nothing downstream ever sees the multi-rank keys the sort needed. collapse_group_columns sheds its rows parameter and renumbering pass; the shared collapses() predicate decides both sides.
compute_summaries runs between setup_columns and apply_formats, on the raw numeric values, and its chunks flow to build_cells. End-to-end tests cover grand and group placement, rowlabel, clause order, separated-facet re-keying, and the error paths.
thomasp85
left a comment
There was a problem hiding this comment.
How does this behave for 0 row tables? I agree it's not a use case that makes sense but it needs to error gracefully and in the same way for group and grand summaries.
It would be nice to have a test that ensured that the summary and aggregate functions never drifted apart
How should we deal with summaries that create un-allowed calculations, e.g. {mean/0} or geomean on negative values.. They'd return NaN or Inf but maybe we shouldn't display that?
We were emitting 0 rows for groups and 1 row of null results for grand. Agreed it should just error, good catch.
The alternative is to display
There is drift already, I think aggregate |
# Conflicts: # doc/vendor/SKILL.md # src/execute/table/format.rs # src/execute/table/layout.rs # src/execute/table/mod.rs # src/parser/builder.rs # src/table/mod.rs
This PR adds a row-summarising clause to the tabulate syntax.
I think the doc pages give the best introduction, but briefly:
Adds a new row after every group which will the display the summarised mean for the
bill_lenandbill_depcolumns.Is typical syntax for a standard clause. Notably, the operation (
meanin the example) can be a template with keywords and limited arithmetic, so that e.g.({mean - se}, {mean + se})will render to something like(0.08, 12.04).The row labels for summary rows are placed in the same columns stub row labels (
FORMAT STUB). If no suitable stub column exists, one will be created.