Skip to content

Enable cols_align and cols_label for gt_group objects - #2010

Merged
rich-iannone merged 11 commits into
rstudio:masterfrom
shannonhaughton:gt_group
Jul 8, 2025
Merged

rich-iannone merged 11 commits into
rstudio:masterfrom
shannonhaughton:gt_group

Conversation

@shannonhaughton

@shannonhaughton shannonhaughton commented Jul 8, 2025 •

Copy link
Copy Markdown
Contributor

Summary

In this pr I have created a function apply_to_grp which enables functions such as cols_align and cols_label to apply to gt_group objects.

Notes:

  1. This can be applied to many more of the functions within the package such as cols_hide, cols_width etc. I have begun with a simple pr of only two functions to assess method, but am more than happy to add the functionality elsewhere once an approach has been agreed.
  2. A lot of functions used @inheritParams cols_align. I switched these over to cols_hide for now as I haven't made updates to all functions and I wished to update the data parameter in align.
  3. To keep this simple I've gone with the 'all or nothing' approach of applying the function called to every table within the group. If a column was referenced in the call but not present in one of the groups, an error will occur pointing out which table caused the problem.

Related GitHub Issues and PRs

Fixes: #2005

Checklist

@CLAassistant

CLAassistant commented Jul 8, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rich-iannone

Copy link
Copy Markdown
Member

This looks great! I've fixed up one test in tests/testthat/test-input_data_validation.R (now flexible for error message concerning gt_tbl and gt_group objects) so that all tests pass.

The general approach is good and applying the function to all tables in a group (w/ all or nothing strategy) also seems good! Thanks for this wonderful, first contribution to the package!

@rich-iannone rich-iannone left a comment

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.

LGTM!

@rich-iannone
rich-iannone merged commit 722eac2 into rstudio:master Jul 8, 2025
@shannonhaughton
shannonhaughton deleted the gt_group branch July 9, 2025 14:55
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.

enable functions such as cols_label() and cols_align() for gt_grp objects

3 participants