-
-
Notifications
You must be signed in to change notification settings - Fork 40
Implement improved tinytable support #1141
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @strengejacke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the flexibility of table output by integrating support for the tinytable package. Users can now choose between the existing gt engine and the new tinytable engine for rendering HTML and markdown tables generated by display and print methods for model parameters, providing more options for table presentation.
Highlights
- New
engineparameter: I've introduced anengineargument todisplay.parameters_model,display.compare_parameters, andprint_html.parameters_modelfunctions. This new parameter allows users to specify the desired table rendering backend, defaulting to 'gt'. tinytableintegration: This pull request enables the use of thetinytablepackage for rendering HTML and markdown tables. Whenengine = "tt"is specified, the output will be generated usingtinytableinstead of the defaultgtpackage.- Conditional styling application: I've implemented logic within
print_html.parameters_modelto conditionally applygtspecific styling options. These styling functions (.add_gt_options) will now only be called when thegtengine is in use, ensuring thattinytableoutput is not inadvertently styled withgt's specific formatting. - Documentation updates: I've updated the R documentation files (
.Rd) fordisplay.parameters_modelandprint.parameters_modelto reflect the addition of the newengineparameter and its available options ('gt', 'default', 'tt').
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces support for tinytable as a rendering engine by adding an engine parameter to several functions. I've identified a critical issue in R/display.R where the engine parameter is being passed incorrectly to downstream functions, potentially causing existing function calls to fail. Suggestions have been provided to address this.
|
@easystats/core-team FYI, This makes a lot of formatting in other packages, like in this PR, redundant, since grouping rows/columns is now fully done in |
|
@gemini-code-assist review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements improved support for the tinytable package as an alternative HTML/markdown table rendering engine. The main purpose is to provide users with an additional option for creating formatted tables that can dynamically adapt to different output environments (R Markdown, Jupyter Notebooks, etc.).
- Add
display()function withformat = "tt"option to use tinytable package - Replace parameter name-based grouping with numeric position-based grouping in examples and tests
- Remove deprecated
print_table()function in favor of the newdisplay()approach
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vignettes/model_parameters_print.Rmd | Update documentation examples to use position-based parameter grouping and document tinytable support |
| tests/testthat/test-printing.R | Convert parameter grouping from name-based to position-based indexing |
| tests/testthat/test-marginaleffects.R | Update expected column names in test assertions |
| tests/testthat/test-include_reference.R | Add tinytable dependency check and test display() function |
| tests/testthat/test-compare_parameters.R | Split tests and convert to position-based grouping, add tinytable tests |
| R/print_html.R | Add tinytable engine support and update column grouping logic |
| R/display.R | Add tinytable format support and update documentation |
| R/print_md.R | Remove tinytable-specific logic, simplify to use standard markdown export |
| R/print_table.R | Remove entire file (deprecated function) |
| man/*.Rd | Update documentation to reflect tinytable support and new engine parameter |
Comments suppressed due to low confidence (1)
tests/testthat/test-include_reference.R:2
- The addition of the knitr dependency check appears unrelated to the tinytable improvements. Consider documenting why this additional check is necessary or if it should be in a separate change.
skip_if_not_installed("knitr")
| # More advances tables and markdown / HTML formatting | ||
|
|
||
| The `print_md()` as well as `print_html()` functions can be used to create markdown (for knitting to PDF or Word) and HTML tables. | ||
| The `print_md()` as well as `print_html()` functions can be used to create markdown (for knitting to PDF or Word) and HTML tables, where HTML tables are created using the [**gt**](https://gt.rstudio.com/) package. There is also a `display()` function, which internally calls `print_md()` or `print_html()`, depending on the `format` argument. However, for `display()`, the `format` argument can also be `"tt"` to use the [**tinytable**](https://vincentarelbundock.github.io/tinytable/) package as engine to produce tables. This will create tables in different output formats, depending on the environment where the code is run (e.g. R Markdown, Jupyter Notebook, etc.). |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This is a very long sentence that could be broken down for better readability. Consider splitting it into 2-3 shorter sentences for improved clarity.
| The `print_md()` as well as `print_html()` functions can be used to create markdown (for knitting to PDF or Word) and HTML tables, where HTML tables are created using the [**gt**](https://gt.rstudio.com/) package. There is also a `display()` function, which internally calls `print_md()` or `print_html()`, depending on the `format` argument. However, for `display()`, the `format` argument can also be `"tt"` to use the [**tinytable**](https://vincentarelbundock.github.io/tinytable/) package as engine to produce tables. This will create tables in different output formats, depending on the environment where the code is run (e.g. R Markdown, Jupyter Notebook, etc.). | |
| The `print_md()` and `print_html()` functions can be used to create markdown and HTML tables. Markdown tables are suitable for knitting to PDF or Word, while HTML tables are created using the [**gt**](https://gt.rstudio.com/) package. | |
| There is also a `display()` function, which internally calls `print_md()` or `print_html()` depending on the `format` argument. For `display()`, the `format` argument can also be `"tt"`, which uses the [**tinytable**](https://vincentarelbundock.github.io/tinytable/) package as the engine to produce tables. | |
| This allows the creation of tables in different output formats, depending on the environment where the code is run (e.g., R Markdown, Jupyter Notebook, etc.). |
| line_padding = line_padding, | ||
| user_labels = column_labels | ||
| ) | ||
| if (identical(engine, "tt")) { |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional check for tinytable engine is repeated multiple times in this file. Consider extracting this logic into a helper function to reduce code duplication.
| if (identical(engine, "tt")) { | |
| if (is_tinytable_engine(engine)) { |
| #' [`principal_components()`]. | ||
| #' @param format String, indicating the output format. Can be `"markdown"` | ||
| #' or `"html"`. | ||
| #' `"html"`, or `"tt"`. `format = "tt"` creates a `tinytable` object, which is |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The documentation comment uses inconsistent formatting. The backticks around 'format = "tt"' should be consistent with other code references in the comment block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request introduces improved tinytable support by refactoring table generation logic and unifying the API with the display() function. This results in cleaner and more maintainable code. There are opportunities to reduce code duplication by extracting the engine validation and line separator logic into helper functions.
| # which engine? | ||
| engine <- insight::validate_argument( | ||
| getOption("easystats_html_engine", engine), | ||
| c("gt", "default", "tt") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code for validating the HTML engine is repeated in several print_html.* functions (e.g., print_html.compare_parameters, print_html.parameters_efa) and other files. To improve maintainability and reduce code duplication, you could extract this logic into a helper function.
.validate_html_engine <- function(engine = "gt") {
insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
}| # line separator - for tinytable, we have no specific line separator, | ||
| # because the output format is context-dependent | ||
| line_sep <- ifelse(identical(engine, "tt"), " ", "<br>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.