Replace gt with lt for summary tables (#371) - #372
Open
yihui wants to merge 3 commits into
Open
Conversation
Replace the heavy gt dependency with the lightweight lt package for
rendering simulation summary tables.
- Add lt to Imports; keep gt in Suggests for the deprecated as_gt().
- Add R/lt.R: re-export the lt() generic and port
as_gt.simtrial_gs_wlr() to lt.simtrial_gs_wlr(). lt has no tidyselect,
so spanner/label columns are enumerated explicitly and moved into
contiguous blocks with lt_move().
- Deprecate as_gt(): the generic now emits .Deprecated("lt", ...) and the
simtrial_gs_wlr method guards with assert_gt_installed(). It still
returns a gt_tbl for one release.
- Convert all vignettes gt -> lt.
- pkgdown: reference lt.simtrial_gs_wlr; NEWS: add major-changes entry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The raw output of sim_gs_n() carries the "simtrial_gs_wlr" class but lacks the attributes added by summary(). Since the re-exported lt() generic now dispatches to lt.simtrial_gs_wlr(), guard the method: when the object is not a summary (no compare_with_design attribute), fall back to a plain lt table, mirroring how bare gt() rendered it before. Fixes the vignette build failure in CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regenerate man pages so links to lt() and lt-methods resolve to the local topics instead of gsDesign. The initial roxygen run predated the lt re-export being loaded, so it mis-resolved [lt-methods] to gsDesign:lt-methods, tripping the "error on warning" R CMD check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
yihui
commented
Sep 2, 2026
Comment on lines
+135
to
+142
| # lt has no tidyselect, so enumerate the columns of each spanner explicitly. | ||
| # Spanned columns must be contiguous, which is ensured by the lt_move() calls | ||
| # below (mirroring gt::cols_move() in as_gt()). | ||
| time_cols <- grep("_time$", names(x), value = TRUE) | ||
| event_cols <- grep("_event$", names(x), value = TRUE) | ||
| n_cols <- grep("_n$", names(x), value = TRUE) | ||
| upper_cols <- grep("_upper_prob$", names(x), value = TRUE) | ||
| lower_cols <- grep("_lower_prob$", names(x), value = TRUE) |
Collaborator
Author
There was a problem hiding this comment.
This part of code is ugly (although works), and will be improved in the next version of {lt}: yihui/lt#5
Comment on lines
+182
to
+183
| do.call(lt::lt_label, c(list(ans), labels)) |> | ||
| lt::lt_header(title = title, subtitle = subtitle) |
Collaborator
Author
There was a problem hiding this comment.
this ugly do.call() will also be gone with the next version of {lt}: yihui/lt#5
Suggested change
| do.call(lt::lt_label, c(list(ans), labels)) |> | |
| lt::lt_header(title = title, subtitle = subtitle) | |
| ans |> lt::lt_label(labels) |> | |
| lt::lt_header(title = title, subtitle = subtitle) |
Comment on lines
+127
to
+130
| lt::lt() |> | ||
| lt::lt_label(sim_time = "Time", sim_n = "N", sim_event = "Event", sim_upper_prob = "Crossing probability") |> | ||
| lt::lt_move(columns = c("sim_time", "sim_n", "sim_event"), after = "analysis") |> | ||
| lt::lt_header(title = title, subtitle = subtitle) |
Collaborator
Author
There was a problem hiding this comment.
used lt::lt() instead of lt() for consistency with the lt::lt_*() lines, although a bare lt() works
yihui
marked this pull request as ready for review
September 2, 2026 21:35
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
Replaces the heavy gt dependency with the lightweight lt package for rendering simulation summary tables, mirroring gsDesign2 PR #629 and gsDesign PR #282. Closes #371.
ltto Imports; keepgtin Suggests (still used by the deprecatedas_gt()).R/lt.R(new): re-export thelt()generic solt()dispatches after loading only simtrial; portas_gt.simtrial_gs_wlr()tolt.simtrial_gs_wlr(). Since lt has no tidyselect, spanner/label columns are enumerated explicitly (grep()), and paired asymptotic/simulated columns are moved into contiguous blocks withlt_move()before applyinglt_spanner(). Two-branch logic (compare_with_design) and the two-sided extra spanner are preserved.R/as_gt.R:as_gt()generic now emits.Deprecated("lt", ...);as_gt.simtrial_gs_wlr()guards withassert_gt_installed(). Still returns agt_tblfor one release.as_gt.fixed_design/as_gt.gs_designredirection shims left as-is.gt→ltcalls; droppedlibrary(lt)where only the re-exportedlt()is used (rmst); switchedrequireNamespace("gt")gates tolt.lt.simtrial_gs_wlralongsideas_gt.simtrial_gs_wlr.Verification
R CMD INSTALL+ smoke test: afterlibrary(simtrial)alone,summary(...) |> lt()returns anlt_tblfor all three branches (no-design, one-sided, two-sided);as_gt()warns once and returns agt_tbl.gt::/library(gt)outside the intentionally-kept deprecatedas_gt()internals and doc references.Known issue (pre-existing, not from this PR)
The
test-unvalidated-sim_gs_n.R/test-unvalidated-summary.Rparallel tests error withcould not find function "convert_list_to_df_w_list_cols"/create_cutinside doFuture workers. This reproduces on the base branch and is a parallel-backend globals-detection issue, unrelated to the gt→lt change. Left for follow-up.Follow-up
After merge, file an issue (like gsDesign2#663) to fully remove gt and
as_gt()in a future release.🤖 Generated with Claude Code