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

gt_merge_stack not working correctly #55

Closed
brett250000 opened this issue Jun 16, 2022 · 1 comment
Closed

gt_merge_stack not working correctly #55

brett250000 opened this issue Jun 16, 2022 · 1 comment
Assignees

Comments

@brett250000
Copy link

It appears that the gt_merge_stack function is not working correctly if you are grouping first by another field. I was just looking at the example with NFL teams and noticed that the Ravens are not in the NFC West.
image

Worth noting that if you don't group by conference, the gt_merge_stack field displays correctly.
image

library(gt) 
library(gtExtras)

team_df <- readRDS(url("https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds"))

team_df %>%
  dplyr::select(team_nick, team_abbr, team_conf, team_division, team_logo_wikipedia, team_wordmark) %>%
  gt(groupname_col = "team_conf") %>%
  # gt() %>%
  gt_merge_stack(col1 = team_nick, col2 = team_division) %>%
  gt_img_rows(team_logo_wikipedia) %>%
  gt_img_rows(team_wordmark)
@jthomasmock
Copy link
Owner

Thanks for heads up! Please install latest dev version for fix - that function is now using gtExtras::gt_index() internally which is group-safe.

library(gt) 
library(gtExtras)

team_df <- readRDS(url("https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds"))

set.seed(36)
team_df %>%
  dplyr::slice_sample(n = 12) %>%
  dplyr::select(team_nick, team_abbr, team_conf, team_division, team_logo_wikipedia, team_wordmark) %>%
  gt(groupname_col = "team_conf") %>%
  gt_merge_stack(col1 = team_nick, col2 = team_division) %>%
  gt_img_rows(team_logo_wikipedia) %>%
  gt_img_rows(team_wordmark) 

Created on 2022-06-16 by the reprex package (v2.0.1)

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

No branches or pull requests

2 participants