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

summary_rows() for one group in multi-group table #545

Closed
steveputman opened this issue Apr 14, 2020 · 0 comments · Fixed by #1159
Closed

summary_rows() for one group in multi-group table #545

steveputman opened this issue Apr 14, 2020 · 0 comments · Fixed by #1159

Comments

@steveputman
Copy link
Contributor

When a table has multiple grouping variables (and therefore the groupnames show up as Group 1 - Subgroup 1), is it possible to generate summary_rows for the group higher in the hierarchy (Group 1 in this example)?

I have tried calling out only the "higher" group in addition to the subgrouping you get with groups = TRUE but get an error.

library(tidyverse)
library(gt)

exibble %>%
  mutate(subgroup = c(1,1,2,2,1,1,2,2)) %>%
  gt(groupname_col = c("group", "subgroup"),
     rowname_col = "row") %>%
  summary_rows(groups = TRUE,
               columns = vars(num),
               fns = list(Total = ~sum(., na.rm = TRUE))) %>%
  summary_rows(groups = "group",
               columns = vars(num),
               fns = list(Total = ~sum(., na.rm = TRUE)))
#> Error: All `groups` should be available in the gt object:
#>  * The following groups aren't present: group

Created on 2020-04-14 by the reprex package (v0.3.0)

Thanks and congrats on getting it onto CRAN!

Steve

@rich-iannone rich-iannone added this to the FUTURE milestone Aug 22, 2022
@rich-iannone rich-iannone changed the title summary_rows for one group in multi-group table summary_rows() for one group in multi-group table Aug 24, 2022
@rich-iannone rich-iannone self-assigned this Dec 10, 2022
@rich-iannone rich-iannone moved this from Backlog to Done in R Markdown Team Projects Dec 10, 2022
@rich-iannone rich-iannone modified the milestones: FUTURE, v0.9.0 Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment