Closed lorenzoFabbri closed 3 months ago
@vincentarelbundock I received a notification for a reply from you, but I cannot seem to see it here!
I tried to use group_tt
, but how can I add the spanners without specifying the indices?
Yes, I deleted the answer because I had not understood the question.
You can do this now, but not automatically without specifying the indices. It would be trivial to implement, but I'm not sure what makes sense for the user interface.
For completeness:
df <- tibble::as_tibble(mtcars) |>
dplyr::mutate(am = as.factor(am))
splits <- split(seq_along(df$am), df$am)
splits <- lapply(splits, function(x) {x[1]})
tinytable::tt(df) |>
tinytable::group_tt(i = splits)
Maybe there's a cleaner version but this should work for simple cases.
Thanks, this looks good.
Your code does raise a question, though: The implementation is so trivial that I'm not sure I should increase code complexity. Perhaps an example in the documentation would be sufficient.
I completely agree. I thought it was more difficult to implement. Feel free to close the issue!
Cool. I added a base R version of your example to the docs. This is a nice addition, thanks!
https://vincentarelbundock.github.io/tinytable/vignettes/group.html#automatic-row-groups
Sorry for the dumb question but I did not find any example in the tutorials. I would like to replicate the following piece of code with
tinytable
:That is, I'd like to be able to use a column of my dataset to create groups in the table.