gtsummary icon indicating copy to clipboard operation
gtsummary copied to clipboard

Trial dyn [email protected]@main

Open Melkiades opened this issue 10 months ago • 5 comments

What changes are proposed in this pull request? Integrate table printouts within example sections by leveraging raw html and decoupled file writing and reading.

If there is an GitHub issue associated with this pull request, please provide link.


Reviewer Checklist (if item does not apply, mark is as complete)

  • [ ] Ensure all package dependencies are installed by running renv::install()
  • [ ] PR branch has pulled the most recent updates from master branch. Ensure the pull request branch and your local version match and both have the latest updates from the master branch.
  • [ ] If an update was made to tbl_summary(), was the same change implemented for tbl_svysummary()?
  • [ ] If a new function was added, function included in _pkgdown.yml
  • [ ] If a bug was fixed, a unit test was added for the bug check
  • [ ] Run pkgdown::build_site(). Check the R console for errors, and review the rendered website.
  • [ ] Code coverage is suitable for any new functions/features. Review coverage with withr::with_envvar(new = c("NOT_CRAN" = "true"), covr::report()). Begin in a fresh R session without any packages loaded.
  • [ ] R CMD Check runs without errors, warnings, and notes
  • [ ] usethis::use_spell_check() runs with no spelling errors in documentation

When the branch is ready to be merged into master:

  • [ ] Update NEWS.md with the changes from this pull request under the heading "# gtsummary (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (see NEWS.md for examples).
  • [ ] Increment the version number using usethis::use_version(which = "dev")
  • [ ] Run codemetar::write_codemeta()
  • [ ] Run usethis::use_spell_check() again
  • [ ] Approve Pull Request
  • [ ] Merge the PR. Please use "Squash and merge".

Melkiades avatar Apr 17 '24 14:04 Melkiades

@Melkiades this is looking awesome! Thinking ahead to other output formats, e.g. kableExtra, flextable. We may need to have functionality for displaying pngs for these formats as well? 🤔

ddsjoberg avatar Apr 17 '24 19:04 ddsjoberg

FYI, as of yesterday, gt tables can be printed directly in the examples section on pkgdown sites https://github.com/r-lib/pkgdown/pull/2493

But our solution is still amazing because they'll appear in the help files

ddsjoberg avatar May 01 '24 04:05 ddsjoberg

Regarding the color. Perhaps we can make it a part of our print method to make the background white? https://gt.rstudio.com/reference/tab_style.html

The markdown bit is confusing. What if we added gt::fmt_markdown(everything()) to our print method? Does that solve it?

ddsjoberg avatar May 17 '24 22:05 ddsjoberg

gt::fmt_markdown(everything())

I tried both. The second does make the text invisible while the first one got me here Screenshot 2024-05-21 165901

The generating table is the following (with the enforced setting):

  trial |>
    select(age, grade, response, trt) |>
    tbl_summary(
      by = trt,
      label = list(age = "Patient Age"),
      statistic = list(all_continuous() ~ "{mean} ({sd})"),
      digits = list(age = c(0, 1))
    ) |>
    as_gt() |>
    gt::tab_options() |>
    gt::tab_style(
      style = list(
        gt::cell_fill(color = "white"),
        gt::cell_text(color = "black"),
        gt::cell_borders(color = "lightgrey", sides = c("top", "bottom"))
      ),
      locations = gt::cells_body()
    ) 

The lightgrey is not respected. See the following from viewer Screenshot 2024-05-21 165945

I have the feeling that these two are bugs/unexpected behavior from roxygen2

Melkiades avatar May 21 '24 15:05 Melkiades

Let's put this on hold until we're further along with the unit testing. this is a lovely to have, and the unit tests are a must-have

ddsjoberg avatar Jun 25 '24 16:06 ddsjoberg

Hey hey @Melkiades , Thanks for working on this! Since the pkgdown site can now print the gt tables in the examples section, I think we can keep our pkg a bit simpler by skipping this feature. Thanks for looking into it!

ddsjoberg avatar Jul 07 '24 22:07 ddsjoberg