Skip to content

Row groups merge when there is only one unique value in a rowname_col #2121

@SJ-31

Description

@SJ-31

Prework

Description

If a row group X only has a single unique value in one of its rowname_col (with 2+ rowname_cols), the label for X will merge into the values of the preceding row group. Also, the group after X will merge into X's values

Reproducible example

  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.
# Row group D only has `1` for rowname_col `symbol`
sample_data <- tibble::tibble(
  subject = c(rep("A", 3), rep("B", 4), rep("C", 2), rep("D", 2), rep("E", 3)),
  symbol = c(
    1,
    1,
    2,
    1,
    1,
    2,
    2,
    1,
    1,
    1,
    2,
    2,
    2,
    1
  ),
  value = runif(14),
  v2 = runif(14)
)
gt::gt(
  sample_data,
  rowname_col = c("symbol", "value"),
  groupname_col = "subject"
)
Image

Expected result

Row group "D" shouldn't merge into the values of "C" and "E" shouldn't merge into the values of group "D".

Session info

Created on 2026-01-28 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.2 (2025-10-31)
#>  os       EndeavourOS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Asia/Bangkok
#>  date     2026-01-28
#>  pandoc   3.5 @ /usr/bin/ (via rmarkdown)
#>  quarto   1.8.27 @ /usr/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.5   2025-04-23 [1] CRAN (R 4.5.0)
#>  digest        0.6.39  2025-11-19 [1] CRAN (R 4.5.2)
#>  evaluate      1.0.5   2025-08-27 [1] CRAN (R 4.5.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.5.0)
#>  fs            1.6.6   2025-04-12 [1] CRAN (R 4.5.0)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.5.0)
#>  htmltools     0.5.9   2025-12-04 [1] CRAN (R 4.5.2)
#>  knitr         1.51    2025-12-20 [1] CRAN (R 4.5.2)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.5.0)
#>  otel          0.2.0   2025-08-29 [1] CRAN (R 4.5.2)
#>  pillar        1.11.1  2025-09-17 [1] CRAN (R 4.5.2)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.5.0)
#>  rlang         1.1.6   2025-04-11 [1] CRAN (R 4.5.0)
#>  rmarkdown     2.30    2025-09-28 [1] CRAN (R 4.5.2)
#>  sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.5.1)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.5.0)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun          0.55    2025-12-16 [1] CRAN (R 4.5.2)
#>  yaml          2.3.12  2025-12-10 [1] CRAN (R 4.5.2)
#> 
#>  [1] /home/shannc/R/x86_64-pc-linux-gnu-library/4.5
#>  [2] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions