Skip to content

Replace gt with lt for summary tables (#371) - #372

Merged
LittleBeannie merged 9 commits into
mainfrom
gt-to-lt-371
Sep 4, 2026
Merged

Replace gt with lt for summary tables (#371)#372
LittleBeannie merged 9 commits into
mainfrom
gt-to-lt-371

Conversation

@yihui

@yihui yihui commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

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.

  • DESCRIPTION: add lt to Imports; keep gt in Suggests (still used by the deprecated as_gt()).
  • R/lt.R (new): re-export the lt() generic so lt() dispatches after loading only simtrial; port as_gt.simtrial_gs_wlr() to lt.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 with lt_move() before applying lt_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 with assert_gt_installed(). Still returns a gt_tbl for one release. as_gt.fixed_design / as_gt.gs_design redirection shims left as-is.
  • Vignettes (7): converted gtlt calls; dropped library(lt) where only the re-exported lt() is used (rmst); switched requireNamespace("gt") gates to lt.
  • pkgdown: reference lt.simtrial_gs_wlr alongside as_gt.simtrial_gs_wlr.
  • NEWS: major-changes entry referencing Migrate to {lt} #371.

Verification

  • R CMD INSTALL + smoke test: after library(simtrial) alone, summary(...) |> lt() returns an lt_tbl for all three branches (no-design, one-sided, two-sided); as_gt() warns once and returns a gt_tbl.
  • Grep confirms no stray gt::/library(gt) outside the intentionally-kept deprecated as_gt() internals and doc references.

Known issue (pre-existing, not from this PR)

The test-unvalidated-sim_gs_n.R / test-unvalidated-summary.R parallel tests error with could not find function "convert_list_to_df_w_list_cols" / create_cut inside 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

yihui and others added 3 commits September 2, 2026 15:15
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>
Comment thread R/lt.R Outdated
Comment thread R/lt.R
Comment thread R/lt.R
@yihui
yihui marked this pull request as ready for review September 2, 2026 21:35
@yihui
yihui requested a review from jdblischak September 2, 2026 21:36
Comment thread vignettes/discrepancy-between-simtrial-and-survival.Rmd Outdated
Comment thread vignettes/rmst.Rmd Outdated
Comment thread vignettes/routines.Rmd Outdated
@jdblischak

Copy link
Copy Markdown
Collaborator

Also, below are the tables from the example code rendered using {gt} versus {lt}. It looks like the {lt} table is missing the spanner "Probability of crossing efficacy bounds under H1".

gt

Using {simtrial} 1.0.2 installed from CRAN:

example("as_gt", package = "simtrial")
image image

lt

Using {simtrial} built from this PR branch:

example("lt-methods", package = "simtrial")
image image

yihui and others added 5 commits September 3, 2026 14:47
Co-authored-by: John Blischak <jdblischak@gmail.com>
The two summary tables in this vignette were previously commented out. Convert
them from gt to lt and uncomment. gt::fmt_number(columns = everything()) had no
direct lt equivalent (lt lacks tidyselect), so select the numeric columns
explicitly with names(fr)[sapply(fr, is.numeric)].

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s like 'senario', 'period', 'duration' are integers and shouldn't have 2 decimal places)
lt matches each spanner to the visual position of its first column, then
spans the next length(columns) columns. The spanner columns were listed in
grep() (original-name) order, e.g. c("sim_time", "asy_time"), but lt_move()
lays them out asymptotic-before-simulated, e.g. c("asy_time", "sim_time").
The mismatched first column shifted every spanner's colspan, cascading
until the last spanner ("Probability of crossing efficacy bounds under H1")
had no column to anchor to and was silently dropped from the rendered table.

List each spanner's columns in the same paired asy-before-sim order that
lt_move() uses, reusing shared vectors so the move layout and the spanner
selections cannot drift apart. Verified (via a node-baked render) that the
one-sided table now shows Time/N/Events/Efficacy and the two-sided table
additionally shows Futility.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui

yihui commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

Also, below are the tables from the example code rendered using {gt} versus {lt}. It looks like the {lt} table is missing the spanner "Probability of crossing efficacy bounds under H1".

That was a bug in {lt} and has been fixed. For now, I'm using a workaround, which can be simplified after the next {lt} release (#373).

@jdblischak jdblischak 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.

The spanner from the example table is now displayed correctly:

Image

Thanks @yihui!

Comment thread vignettes/discrepancy-between-simtrial-and-survival.Rmd
@LittleBeannie
LittleBeannie merged commit 01452a6 into main Sep 4, 2026
9 checks passed
@LittleBeannie
LittleBeannie deleted the gt-to-lt-371 branch September 4, 2026 21:08
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.

Migrate to {lt}

3 participants