Skip to content

Conversation

@rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented Aug 9, 2022

This PR focuses on some first steps to improving the appearance and functionality of the gt table stub.

The first fixes (a prelude, really) involve improving the default alignments of content in the stub. With the stub serving either as row labels or indices, it's important to discern which is which and this is done as part of the auto-alignment routine in the gt() function.

The main thing after that is to introduce the first-class ability to set indentation on the stub elements. This is important enough to require a new function with a specialized interface for this task (tab_stub_indent()).

Here is a runnable example that demonstrates one use of tab_stub_indent():

library(gt)
library(tidyverse)

exibble %>%
  select(-c(fctr, date, time, datetime)) %>%
  gt(rowname_col = "row", groupname_col = "group") %>%
  sub_missing() %>%
  summary_rows(
    groups = TRUE,
    columns = num,
    fns = list(
      average = "mean",
      total = "sum",
      SD = "sd"
    )
  ) %>%
  tab_options(row_group.as_column = TRUE) %>%
  tab_stub_indent(indent = 2, rows = matches("2|3|6"))

tab-stub-indent-example

@rich-iannone rich-iannone marked this pull request as ready for review August 10, 2022 21:05
@rich-iannone rich-iannone requested a review from cscheid August 10, 2022 21:10
Copy link
Member

@cscheid cscheid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the kind of thing that's best done by adding a new concept ("indent") or should it be left to user CSS instead?

@rich-iannone
Copy link
Member Author

rich-iannone commented Aug 10, 2022

IMO it’s far better to make this first class with its own function since it’s meant to establish structure and the implementation is different across output types.

Copy link
Member

@cscheid cscheid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@rich-iannone rich-iannone merged commit 0be501c into master Aug 10, 2022
@rich-iannone rich-iannone deleted the stub-indentation branch August 10, 2022 21:56
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.

3 participants