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

tab_style fails to target all cell_summary rows #472

Closed
steveputman opened this issue Jan 21, 2020 · 3 comments
Closed

tab_style fails to target all cell_summary rows #472

steveputman opened this issue Jan 21, 2020 · 3 comments

Comments

@steveputman
Copy link
Contributor

Applying tab_style to cells_summary can result in erratic behavior (in my case, styling some but not all of the summary rows). It seems to pop up more often when there are more groups, but there is some pattern that is eluding me: with 1 row and 1 group, it happens every time. With 2 rows and 1 group, it seems never to happen. With 2 rows and 2 groups, it happens to the first group (if the rows are members of different groups) every time. But 1-row groups don't seem to be the issue--in my use case, all groups have 2 members: summary rows for the first 7 groups style as expected, and the remainder of the summary rows are unformatted (in my case, there are 6 more groups). Easiest example (1 row and 1 group) shown in reprex.

library(tidyverse)
library(gt)
library(babynames)

numrows <- 1
numgroups <- 1

df <- tibble::tibble(
  name = sample(babynames$name, numrows), 
  value = runif(numrows, 50000, 2000000), 
  group = sample(letters[1:numgroups], numrows, replace = TRUE)
) 

gttbl <- df %>%
  group_by(group) %>%
  arrange(group) %>%
  gt(rowname_col = "name") %>%
  summary_rows(groups = TRUE, columns = vars(value), fns = list("sum")) %>%
  tab_style(style = list(cell_text(style = "italic")),
            locations = cells_summary())

gttbl

value

a

Elijaha

1865195

sum

1,865,194.99

Created on 2020-01-21 by the reprex package (v0.3.0)

@rich-iannone
Copy link
Member

Thanks for this detailed look. I was able to reproduce all of the scenarios you outlined. This definitely requires a fix.

@j-krogh
Copy link

j-krogh commented May 20, 2020

I have also had this issue and a similar one when trying to apply text transforms to cells that have been grouped. I suspect the underlying issue is the same.

@rich-iannone rich-iannone added this to the v0.3.1 milestone Jun 21, 2021
@rich-iannone
Copy link
Member

Testing this again, it seems to work now that #782 has been merged.

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

No branches or pull requests

3 participants