Skip to content

Fix gt_split producing table of NAs#2132

Open
Schiano-NOAA wants to merge 3 commits intorstudio:masterfrom
Schiano-NOAA:master
Open

Fix gt_split producing table of NAs#2132
Schiano-NOAA wants to merge 3 commits intorstudio:masterfrom
Schiano-NOAA:master

Conversation

@Schiano-NOAA
Copy link

@Schiano-NOAA Schiano-NOAA commented Mar 13, 2026

Summary

My colleague @sbreitbart-NOAA and I are working on a project that uses gt to make tables for reports. We utilize the gt_split function in order to break up tables to span multiple pages efficiently. After the v1.3 update, we noticed that the split tables were only working for the first element when splitting by rows. Most tables after that had all NAs and the data was not displayed (for more details and reprex see #2130).

In this PR, I change the element of the split table row dimensions (rownum_i) to match the number of rows that the split contains instead of the initial table split row numbers (this is what I believe was causing the issue). For example, when using gt_split to split a table with 10 rows at row 5 (row_every_n = 5), gt_object$gt_tbls$gt_tbl[[2]]$_stub_df$rownum_i resulted in a split of rows for 6 7 8 9 10 for the second split which make sense when splitting the data initially, but once you use this to call the split table, technically this indexing no longer exists for _data in the "sub-table" resulting in NAs. I address this issue by changing the sequence of row numbers for that element in the object to the sequence matching the same number of elements from the split (i.e. 1 2 3 4 5). I tested the fix using the examples found in the documentation and they work. I also ran devtools::check() and it passed with one note.

Related GitHub Issues and PRs

Checklist

@CLAassistant
Copy link

CLAassistant commented Mar 13, 2026

CLA assistant check
All committers have signed the CLA.

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