Skip to content

Use lt 0.5 selectors for the summary table spanners - #385

Merged
yihui merged 2 commits into
Merck:mainfrom
algoria-contributions:issue-373-lt-selectors
Dec 1, 2026
Merged

yihui merged 2 commits into
Merck:mainfrom
algoria-contributions:issue-373-lt-selectors

Conversation

@algoria-contributions

@algoria-contributions algoria-contributions commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #373.

lt 0.5 has predicate selectors and puts spanner columns in body order, so R/lt.R no longer needs its hand-ordered column vectors.

  • Spanners select their columns by suffix, e.g. ~endsWith(., "_time").
  • lt_label() takes stats::setNames(labels, names(x)) instead of the do.call() splice.
  • DESCRIPTION requires lt (>= 0.5).

The vignette item no longer applies: the vignette already renders fr |> lt() without lt_format().

lt_move() still lists its columns to keep each asymptotic/simulated pair together; a predicate would follow names(x) and change the table. Happy to switch if you prefer that layout.

The rendered HTML is identical to main for one-sided, two-sided, no-design and unsummarised inputs. Tests and R CMD check --as-cran give the same results as main.

Algoria

Spanners select their columns with predicates and lt_label() takes a named
vector, so the hand-ordered column vectors are no longer needed. The
rendered HTML is unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just a minor comment.

Comment thread R/lt.R
Comment on lines +154 to +156
lt::lt_spanner(label = "Time", columns = ~endsWith(., "_time")) |>
lt::lt_spanner(label = "Events", columns = ~endsWith(., "_event")) |>
lt::lt_spanner(label = "N", columns = ~endsWith(., "_n")) |>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the terse syntax?

Suggested change
lt::lt_spanner(label = "Time", columns = ~endsWith(., "_time")) |>
lt::lt_spanner(label = "Events", columns = ~endsWith(., "_event")) |>
lt::lt_spanner(label = "N", columns = ~endsWith(., "_n")) |>
lt::lt_spanner(Time ~ endsWith(., "_time")) |>
lt::lt_spanner(Events ~ endsWith(., "_event")) |>
lt::lt_spanner(N ~ endsWith(., "_n")) |>

@algoria-contributions

Copy link
Copy Markdown
Contributor Author

Thanks! The terse form fails with lt 0.5 and main when the RHS is a predicate (non-character object(s)); yihui/lt#75 fixes it. Once that is released I'll switch to it here and bump the lt requirement. Or merge this as is and I'll send a follow-up, whichever you prefer.

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't realize that. Thanks for yihui/lt#75!

Let's merge this PR for now.

@yihui
yihui merged commit de129ff into Merck:main Dec 1, 2026
9 checks passed
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.

Simplify lt.R using lt predicate selectors and spanner auto-reorder (next lt release)

2 participants