Skip to content
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

The cells_summary() groups arg not working with tidyselect semantics #785

Closed
rich-iannone opened this issue Jun 2, 2021 · 0 comments · Fixed by #1159
Closed

The cells_summary() groups arg not working with tidyselect semantics #785

rich-iannone opened this issue Jun 2, 2021 · 0 comments · Fixed by #1159

Comments

@rich-iannone
Copy link
Member

Using the cells_summary() location helper function requires use of non-default values to get it to work.

The signature for the function is:

cells_summary(
  groups = everything(),
  columns = everything(),
  rows = everything()
)

Here's an MRE which results in an error (expectation is that all summary rows should be styled):

library(gt)

gtcars %>% 
  gt(rowname_col = "model", groupname_col = "mfr") %>%
  summary_rows(
    groups = c("Ford", "Ferrari"),
    columns = year,
    fns = list(`latest year` = ~ max(.)),
    formatter = fmt_number,
    decimals = 0,
    use_seps = FALSE
  ) %>%
  tab_style(
    style = list(
      cell_fill(color = background_color),
      cell_text(color = text_color)
    ),
    locations = cells_summary(groups = everything())
  )
Error: `everything()` must be used within a *selecting* function.
ℹ See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>.
Run `rlang::last_error()` to see where the error occurred. 

With groups in cells_summary(), a vector group ID values must be provided (i.e., groups = "Ferrari" works).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant