Skip to content

Row group labels as a column in stub#855

Merged
rich-iannone merged 75 commits into
masterfrom
row-groups-changes
Jan 13, 2022
Merged

Row group labels as a column in stub#855
rich-iannone merged 75 commits into
masterfrom
row-groups-changes

Conversation

@rich-iannone
Copy link
Copy Markdown
Member

@rich-iannone rich-iannone commented Nov 24, 2021

This PR brings us the ability to display row group labels as a column in the stub. This is made possible with the new option row_group.as_column in tab_options() (default keeps the preexisting behavior).

Here is an example:

library(gt)

exibble %>%
  gt(
    rowname_col = "row",
    groupname_col = "group"
  ) %>%
  tab_header(
    title = md("Data listing from **exibble**"),
    subtitle = md("`exibble` is an R dataset")
  ) %>%
  fmt_number(columns = num) %>%
  fmt_currency(columns = currency) %>%
  tab_footnote(
    footnote = "Using commas for separators.",
    locations = cells_body(
      columns = num,
      rows = num > 1000
    )
  ) %>%
  tab_footnote(
    footnote = "Using commas for separators.",
    locations = cells_body(
      columns = currency,
      rows = currency > 1000
    )
  ) %>%
  tab_footnote(
    footnote = "Alphabetical fruit.",
    locations = cells_column_labels(columns = char)
  ) %>%
  tab_style(
    style = cell_fill(color = "lightblue"),
    locations = cells_row_groups(groups = "grp_a")
  ) %>%
  tab_options(row_group.as_column = TRUE) %>%
  summary_rows(
    groups = TRUE,
    columns = c(num, currency),
    fns = list(
      min = ~min(., na.rm = TRUE),
      max = ~max(., na.rm = TRUE),
      avg = ~mean(., na.rm = TRUE)),
    formatter = fmt_number,
    use_seps = FALSE
  )

And this is how it appears:
gt_table

Fixes: #291

@rich-iannone rich-iannone requested a review from jcheng5 December 6, 2021 19:15
Comment thread R/utils_render_latex.R

headings_labels <- prepend_vec(headings_labels, "")
headings_vars <- prepend_vec(headings_vars, "::stub")
if (length(stub_layout) > 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a redundant if

@jcheng5
Copy link
Copy Markdown
Member

jcheng5 commented Jan 7, 2022

Simplify create_group_dividers_l

@rich-iannone rich-iannone marked this pull request as ready for review January 12, 2022 00:31
@jcheng5 jcheng5 self-requested a review January 12, 2022 19:57
@rich-iannone rich-iannone merged commit fcabb41 into master Jan 13, 2022
@rich-iannone rich-iannone deleted the row-groups-changes branch January 13, 2022 03:18
rich-iannone added a commit that referenced this pull request Jan 24, 2022
* master:
  Fixes to footer (footnotes and source notes) across all output formats (#864)
  Row group labels as a column in stub (#855)
  Use reusable GHA workflows (#847)
  Increment version number
  v0.3.1 Release Candidate (#821)
  Fix for styles applied to summary cells when row groups are reordered (#814)
  Update image generation functions (#803)
  `cell_text()` fix (#805)
  Add whitespace options for text (#797)
rich-iannone added a commit that referenced this pull request Feb 1, 2022
* master:
  Add ability to set global locale in `gt()` (#866)
  Bug fixes and enhancements to date/time formatters (#801)
  Fixes to footer (footnotes and source notes) across all output formats (#864)
  Row group labels as a column in stub (#855)
  Use reusable GHA workflows (#847)
  Increment version number
  v0.3.1 Release Candidate (#821)
rich-iannone added a commit that referenced this pull request Feb 2, 2022
* master: (23 commits)
  Improve color handling and add tests (#870)
  Change HTML percent sign to literal `%` (#871)
  Add ability to set global locale in `gt()` (#866)
  Bug fixes and enhancements to date/time formatters (#801)
  Update gt_workflow_diagram.svg
  Update gt_parts_of_a_table.svg
  Update README.md
  Add dedicated ISSUE TEMPLATEs
  Update README.md
  Delete README.Rmd
  Update intro-creating-gt-tables.Rmd
  Update LICENSE
  Make corrections to docs (`columns`/`rows`)
  Update _pkgdown.yml
  Fixes to footer (footnotes and source notes) across all output formats (#864)
  Row group labels as a column in stub (#855)
  Use reusable GHA workflows (#847)
  Increment version number
  v0.3.1 Release Candidate (#821)
  Fix for styles applied to summary cells when row groups are reordered (#814)
  ...
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.

Include an option to modify the layout of the row group label

2 participants