Skip to content

Fix grid output with unique groups in groupname_col and row_group_as_column = TRUE #1803

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 3 commits into from
Jul 18, 2024

Conversation

olivroy
Copy link
Collaborator

@olivroy olivroy commented Jul 17, 2024

Split of.

Basically, just due to the fact that like base subsetting,

vctrs::vec_slice(c(1, 2), -integer(0))
#> numeric(0)
c(1, 2)[-integer(0)]
#> numeric(0)

which ends up creating an empty layout in this particular case. I have been bitten by this before ;)

# bug before this PR
df <- data.frame(x = 1:3, y = 4:6, row = c("A", "B", "C"))
gt(df, groupname_col = "row", row_group_as_column = T) |> plot()
#> Error in body[vertical] + n : 
 #> Non-numeric argument

This PR:
image

Split from #1801 as I am still trying to understand what is going on. What currently works, and what doesn't. I'd like to narrow down the issues and I thought this was a straightforward bug fix!

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!

@olivroy olivroy changed the title Fix grid output with unique groups Fix grid output with unique groups in groupname_col and row_group_as_column = TRUE Jul 17, 2024
@rich-iannone rich-iannone merged commit 3c71378 into rstudio:master Jul 18, 2024
13 checks passed
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.

2 participants