Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trial dyn [email protected]@main #1628

Open
wants to merge 14 commits into
base: v2.0
Choose a base branch
from
Open

Conversation

Melkiades
Copy link
Collaborator

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".

R/utils_examples.R Outdated Show resolved Hide resolved
@ddsjoberg
Copy link
Owner

@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? 🤔

R/utils_examples.R Outdated Show resolved Hide resolved
R/utils_examples.R Outdated Show resolved Hide resolved
R/utils_examples.R Outdated Show resolved Hide resolved
R/utils_examples.R Outdated Show resolved Hide resolved
R/utils_examples.R Outdated Show resolved Hide resolved
@ddsjoberg
Copy link
Owner

FYI, as of yesterday, gt tables can be printed directly in the examples section on pkgdown sites
r-lib/pkgdown#2493

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

Copy link
Collaborator Author

@Melkiades Melkiades left a comment

Choose a reason for hiding this comment

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

Now it should pass the tests but we have two remaining issues in the printout: 1. After the first html any markdown used is lost (like if you use a italic text it will not be italic but there will be _). 2. The background follows the colorscheme of rstudio. I honestly do not know how to solve these issues.

Screenshot 2024-05-17 175203

@ddsjoberg
Copy link
Owner

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?

@Melkiades
Copy link
Collaborator Author

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

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.

None yet

2 participants