Fix gt_split producing table of NAs#2132
Open
Schiano-NOAA wants to merge 3 commits intorstudio:masterfrom
Open
Fix gt_split producing table of NAs#2132Schiano-NOAA wants to merge 3 commits intorstudio:masterfrom
Schiano-NOAA wants to merge 3 commits intorstudio:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
My colleague @sbreitbart-NOAA and I are working on a project that uses
gtto make tables for reports. We utilize thegt_splitfunction 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_splitto split a table with 10 rows at row 5 (row_every_n = 5),gt_object$gt_tbls$gt_tbl[[2]]$_stub_df$rownum_iresulted 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
testthatunit tests totests/testthatfor any new functionality.