Skip to content

Tables with row groups#123

Draft
simonsteiger wants to merge 2 commits intoPumasAI:masterfrom
simonsteiger:master
Draft

Tables with row groups#123
simonsteiger wants to merge 2 commits intoPumasAI:masterfrom
simonsteiger:master

Conversation

@simonsteiger
Copy link

Hi,

Thank you for this excellent package!

I often have to work with data that has subgroups nested in several groups. In tables I typically represent that with row groups (I'm taking this term from gt's "nomenclature" https://gt.rstudio.com/).

I've written a simple function to take care of this and was wondering if having such a feature as part of SummaryTables.jl would generally be of interest.

This draft is missing tests and support for a lot of keywords, but I'm happy to add those.

using DataFrames, SummaryTables

data = DataFrame(
    group=repeat(["group x", "group y", "group z"], inner=2),
    subgroup=repeat(["subgroup x", "subgroup y"], outer=3),
    a=collect(1:6),
    b=reverse(collect(1:6)),
)

rowgroup_table(data, :group)

I personally don't like leaving the subgroup column header in, so I would call rename(df, :subgroup => "") before, but I've omitted that here.

image

@jkrumbiegel
Copy link
Collaborator

I'm wondering if this could be a part of simple_table. It looks like your table has no other structure that would warrant a completely new table function. In general, the other special tables have grouping builtin if they need to because it's central to their functionality. Here it's more the presentation that's changed. gt does have a different concept where they try to build any table out of semantic building blocks, which in my experience doesn't always work. So here it's just Cells or some specific table function, which is why I'm wondering if and where it fits.

@jkrumbiegel jkrumbiegel reopened this Jan 23, 2026
@simonsteiger
Copy link
Author

simonsteiger commented Jan 24, 2026

I fully agree with that! I was also feeling some friction / misfit with the existing API.

It wasn't too much work to figure out how to extend simple_table the way I wanted to (I mostly browsed through the code for table_one and simple_table). That being said, it still felt like a feature that could be relevant to others as a pre-written function, so I thought I'd ask you.

Could it be an alternative to have a docs page showing how to use Cell to manually customise tables? Here, extending simple_table to a table with row groups could be an example then. (I guess I should say that I'm happy to write a draft for that)

@jkrumbiegel
Copy link
Collaborator

You mean combining table functions with the basic infrastructure of Cells? I guess I haven't thought about that kind of augmentation yet, I always thought either or

@simonsteiger
Copy link
Author

simonsteiger commented Jan 25, 2026

Sorry for not being very clear there.

You mean combining table functions with the basic infrastructure of Cells?

I guess it would be possible to add a rowgroup_col keyword to simple_table as you suggested in your first reply, if that's what you're referring to. But I am also not sure if it fits with the approach that SummaryTables takes compared to PrettyTables or gt.

Regarding the docs suggestion, I was thinking about extending the Infrastructure section of the docs with an example bringing together the examples from the subsections on Table, Cell, and CellStyle.

Reading through those convinced me that I could set up the table with row gaps as I'd like, but to get there I still consulted the source code for table_one and simple_table. That's of course not a big issue, but giving a more "narrated" example might help other users who want to use SummaryTables not for the builtin functionality that, e.g., table_one brings but for the styling options.

(For context, I have struggled to find a Julia package that allows me to format tables and write to .docx. I'm effectively using SummaryTables as a gt replacement, which is – as you said – not what SummaryTables intends to be.)

@jkrumbiegel
Copy link
Collaborator

Ah if you want to write formatted tables to docx more freely, it might make sense to work directly with WriteDocx.jl and add some convenience functions on top of that. SummaryTables only supports that one style because that's what we need and what's common for publications.

But yes a docs section on making your own table function and using all the building blocks would be great as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants