Feature/sub tfl#27
Merged
billdenney merged 3 commits intomainfrom Apr 29, 2026
Merged
Conversation
tfl_table() and export_tfl.ggtibble() now accept a sub_tfl character vector that splits the output into one sub-table or sub-figure per unique combination of values, removing those columns from the rendered body and appending them to the caption as "label: value; label: value". Formatting is controlled by sub_tfl_sep, sub_tfl_collapse, and sub_tfl_prefix. Sub-table ordering follows factor levels for factor columns and first-appearance order otherwise; the first column of sub_tfl varies outermost. sub_tfl columns may overlap with dplyr::group_vars(x), in which case they are promoted from row-header rendering to the caption. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds section 13 with a worked example, the formatting argument table, ordering rules, group_vars overlap behaviour, and a pointer to the ggtibble equivalent. Renumbers the complete-example section to 14. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
billdenney
commented
Apr 29, 2026
| paste(bad, collapse = ", ") | ||
| )) | ||
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") |
| )) | ||
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") | ||
| checkmate::assert_string(sub_tfl_collapse, .var.name = "sub_tfl_collapse") |
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") | ||
| checkmate::assert_string(sub_tfl_collapse, .var.name = "sub_tfl_collapse") | ||
| checkmate::assert_string(sub_tfl_prefix, .var.name = "sub_tfl_prefix") |
| # first-appearance order. sub_tfl[1] varies outermost (slowest). | ||
| #' @keywords internal | ||
| .compute_sub_tfl_groups <- function(data, sub_tfl) { | ||
| ord_vals <- lapply(sub_tfl, function(col) { |
Member
Author
There was a problem hiding this comment.
Please don't use nested functions, even in lapply. Create a separate function and call it with all required arguments.
| names(ord_vals) <- sub_tfl | ||
|
|
||
| # Build combos with sub_tfl[1] outermost. | ||
| combos <- lapply(ord_vals[[1L]], function(v) { |
Member
Author
There was a problem hiding this comment.
This does not require a nested function. Please do not use one. Just use stats::setNames() directly.
| }) | ||
| pages <- c(pages, sub_pages) | ||
| } | ||
| return(pages) |
Member
Author
There was a problem hiding this comment.
Always omit the extraneous return() call.
| )) | ||
| } | ||
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") |
| } | ||
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") | ||
| checkmate::assert_string(sub_tfl_collapse, .var.name = "sub_tfl_collapse") |
| } | ||
| checkmate::assert_string(sub_tfl_sep, .var.name = "sub_tfl_sep") | ||
| checkmate::assert_string(sub_tfl_collapse, .var.name = "sub_tfl_collapse") | ||
| checkmate::assert_string(sub_tfl_prefix, .var.name = "sub_tfl_prefix") |
- Replace nested anonymous functions in lapply/vapply with named top-level helpers (.ordered_unique_values, .named_one_value, .colspec_not_in, .format_sub_tfl_pair, .format_ggtibble_sub_tfl_pair, .ggtibble_row_pagespec, .attach_page_caption). - Tighten string assertions to assert_character(..., len = 1L, any.missing = FALSE) so the length-1 contract is explicit. - Restructure tfl_table_to_pagelist() as an if/else dispatch over two helpers (.tfl_table_to_pagelist_default and ..._sub_tfl) instead of an early return. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
No description provided.