rstudio / gt

Easily generate information-rich, publication-quality tables from R
https://gt.rstudio.com
Other
1.95k stars 197 forks source link

Feature Request: Allow Nested Row Groups #399

Open billdenney opened 4 years ago

billdenney commented 4 years ago

Groups of rows in data often are nested, and it would be helpful to have row groups support multi-level nesting. As an example from my work, I generate tables to describe adverse events (side effects) in clinical trials of new medicines. Those tables are grouped by organ system (like neurological) then another level of nesting is the group of symptoms (like brain and peripheral nerves) then the actual event (like headache, hallucinations, tremors, or pain in extremities). In practice, there is more complexity than this (https://en.wikipedia.org/wiki/MedDRA).

It would help if the tables could have this multi-level representation like:

|              Title             |
| Stub         | Col1   | Col2   |
| Group level 1                  |
|    Group level 2               |
|       Row 1  | R1C1   | R2C2   |
rich-iannone commented 4 years ago

This is of course a good idea. I’ll have to give some serious thought about how to scale up row groups to allow for nesting.

nicholaelaw commented 3 years ago

I've encountered this problem as well. May I suggest an idea? Concatenate tables. Adapting the previous example, it might be less complicated to simply join two tables

Table 1:
|            Title           |
| Stub     | Col1   | Col2   |
| Group A                    |
|   Row 1  | R1C1   | R2C2   |

Table 2:
|            Title           |
| Stub     | Col1   | Col2   |
| Group B                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |
| Group C                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |

like this:

|            Title           |
| Stub     | Col1   | Col2   |
| Category I                 |
| Group A                    |
|   Row 1  | R1C1   | R2C2   |
| Category II                |
| Group B                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |
| Group C                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |

It would be even better to allow the user to hide a particular level 1 or level 2 headings, to allow for some (poorly conceived) inconsitent table structure:

|            Title           |
| Stub     | Col1   | Col2   |
| Category I                 |
|   Row 1  | R1C1   | R2C2   |
| Category II                |
| Group B                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |
| Group C                    |
|   Row 1  | R1C1   | R2C2   |
|   Row 2  | R1C1   | R2C2   |
pyarasid commented 2 years ago

Much needed

rich-iannone commented 2 years ago

Sorry for the delay on this. Agree this is needed and I hope to work on this soon.

bvarney9 commented 1 year ago

Just curious where this is. It was one of the first things I looked for when creating clinical tables. The table below I manually created the blanks under the row group values.

nested_row_dimensions

RegalPlatypus commented 7 months ago

Just wanted to follow and see if there are any updates on this?

danielfm123 commented 4 months ago

want to follow too

ahasoplakus commented 2 months ago

Would be great to have this

RegalPlatypus commented 1 month ago

Also would love to have this feature.