Skip to content

Summary rows no row groups #1752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 5, 2024

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Jul 5, 2024

Fix #1292 #1420

It is now recommended to use grand_summary_rows(). The error message does a better job to point to the correct solution.

# before
      mtcars %>% dplyr::select(gear) %>% gt::gt(rownames_to_stub = TRUE) %>% gt::summary_rows(
        fns = "sum")
#>      Error:
#>      ! `everything()` must be used within a *selecting* function.
#>     i See <https://tidyselect.r-lib.org/reference/faq-selection-context.html> for details.


# this PR
#>      Error:
#>      ! Since gt v0.9.0, the `groups = everything()` option has been deprecated in `summary_rows()` if no row #> groups are present.
#>       * Use `grand_summary_rows()` instead or add row groups.

Copy link
Collaborator Author

@olivroy olivroy left a comment

Choose a reason for hiding this comment

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

For the moment, I implemented the proposal of #1292, but I think that at this point, it is probably better to deprecate, since this has not worked for a while now.

Comment on lines +566 to +567
input <- tryCatch(rlang::as_label(quo), error = NULL)
if (identical(input, "everything()")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only way I found to figure out if the call was from grand_summary_rows() or not.

Comment on lines 397 to 401
groups <-
resolve_groups(
expr = {{ groups }},
vector = available_groups
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moving the resolver before has forced me to add the isFALSE() condition in the resolver. The groups = FALSE option is undocumented in summary_rows() groups argument, but I wonder if I missed some other edge cases?

Copy link
Member

Choose a reason for hiding this comment

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

I think you might be fine here.

@olivroy olivroy requested a review from rich-iannone July 5, 2024 21:22
@olivroy

This comment was marked as resolved.

Co-authored-by: olivroy <52606734+olivroy@users.noreply.github.com>
@olivroy

This comment was marked as resolved.

Copy link
Member

@rich-iannone rich-iannone 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
Copy link
Member

Thanks! I'll merge once CI is completed.

@rich-iannone rich-iannone merged commit f6c6ff4 into rstudio:master Jul 5, 2024
12 checks passed
@olivroy olivroy deleted the summary-rows-no-row-groups branch July 5, 2024 22: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.

tidyselect error in gt::summary_rows() without groups (in v0.9.0)
2 participants