vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
196 stars 16 forks source link

`i = ...` and `group_tt()` get confusing #334

Closed katossky closed 1 month ago

katossky commented 1 month ago

First thanks for tinytable !

  1. I am not sure it is documented that the i index do count groups as rows.
  2. Neither am I sure it is a good idea! First, this means that a table changes the indexation depending on whether it is grouped or not, and we need to compute the row in artifical ways instead of counting on logic of the table (like we cannot do style_tt(i = iris$Species == 'verticolor', ...) if the table has been grouped).

I do not have a good alternative, but maybe sth along style_tt_groups() or style_tt(scope='groups').

vincentarelbundock commented 1 month ago

Thanks for the note.

I agree this is kind of confusing. I'll think about it, but my intuition is that finding a different solution will increase internal code complexity by a lot. In basically all format, we need to insert new rows of data in the actual table for groups, so we'd have to have special indexing everywhere to keep track of this, and bump up the indices accordingly. It's just much easier to tell LaTeX or JavaScript: "color the 5th row red", than "color the 5th row red unless there are groups, in which case..."

At the moment, I feel that we can probably live with this quirk, perhaps with improved documentation.

katossky commented 1 month ago

You're most probably right, since I don't know anything about your internal gears ! Just sharing my user experience.