jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

Add a new function called `merge_rows` that allows you to merge rows in a column #116

Closed JDenn0514 closed 9 months ago

JDenn0514 commented 9 months ago

Add a new feature called merge_rows that allows people to merge rows in inside a column.

I'm honestly not sure if this is something for gtExtras or gt, but I'm pretty sure it has been suggested in gt already and it hasn't been implemented yet, so I figured I'd suggest it here instead.

I think it would be really useful to allow people to merge cells/rows in a column. Currently this can be done with Flextable, but I like the look and syntax of gt much better than Flextable. I have no idea how to do this so I can't provide suggested code to do this but here is how you do it in Flextable:

library(flextable)
library(dplyr)

flextable(df) %>% 
  merge_v(j="Column1") %>% 
  theme_box() %>% 
  align(j = 1, align = "center")

And here is the ideal output.

I hope that this isn't too big of a lift and is possible to do. Thanks!!

jthomasmock commented 9 months ago

Can you try out this function in gt proper? https://gt.rstudio.com/reference/tab_stub_indent.html

I've played around with this in the past, and it's non-trivial. Also see: https://github.com/rstudio/gt/issues/691 if you'd like to upvote that request.

JDenn0514 commented 9 months ago

Thank you! Both of those suggestions are really helpful! Apologies for the inconvenience, I didn't even realize that's whattab_stub_indent() did. I will also definitely be upvoting that request.