Skip to content

Conversation

@strengejacke
Copy link
Member

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 engine parameter: I've introduced an engine argument to display.parameters_model, display.compare_parameters, and print_html.parameters_model functions. This new parameter allows users to specify the desired table rendering backend, defaulting to 'gt'.
  • tinytable integration: This pull request enables the use of the tinytable package for rendering HTML and markdown tables. When engine = "tt" is specified, the output will be generated using tinytable instead of the default gt package.
  • Conditional styling application: I've implemented logic within print_html.parameters_model to conditionally apply gt specific styling options. These styling functions (.add_gt_options) will now only be called when the gt engine is in use, ensuring that tinytable output is not inadvertently styled with gt's specific formatting.
  • Documentation updates: I've updated the R documentation files (.Rd) for display.parameters_model and print.parameters_model to reflect the addition of the new engine parameter 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

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

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@strengejacke
Copy link
Member Author

@easystats/core-team FYI, insight::export_table() now has arguments for grouping rows and columns, and a better support for the tinytable package (i.e. we have a new option format = "tt"): easystats/insight#1100

This makes a lot of formatting in other packages, like in this PR, redundant, since grouping rows/columns is now fully done in export_table(), and it's pretty straightforward to add full tinytable support.

@strengejacke strengejacke requested a review from Copilot July 21, 2025 13:35
@strengejacke
Copy link
Member Author

@gemini-code-assist review

Copy link
Contributor

Copilot AI left a 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 with format = "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 new display() 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.).
Copy link

Copilot AI Jul 21, 2025

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.

Suggested change
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.).

Copilot uses AI. Check for mistakes.
line_padding = line_padding,
user_labels = column_labels
)
if (identical(engine, "tt")) {
Copy link

Copilot AI Jul 21, 2025

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.

Suggested change
if (identical(engine, "tt")) {
if (is_tinytable_engine(engine)) {

Copilot uses AI. Check for mistakes.
#' [`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
Copy link

Copilot AI Jul 21, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +29 to +33
# which engine?
engine <- insight::validate_argument(
getOption("easystats_html_engine", engine),
c("gt", "default", "tt")
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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")
  )
}

Comment on lines +35 to +37
# line separator - for tinytable, we have no specific line separator,
# because the output format is context-dependent
line_sep <- ifelse(identical(engine, "tt"), " ", "<br>")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The line_sep logic is also repeated in other print_html.* functions. Consider extracting this logic into a helper function to reduce code duplication and improve maintainability.

.get_line_separator <- function(engine) {
  ifelse(identical(engine, "tt"), " ", "<br>")
}

@strengejacke strengejacke marked this pull request as ready for review July 21, 2025 15:32
@strengejacke strengejacke merged commit f0ece7d into main Jul 21, 2025
16 of 19 checks passed
@strengejacke strengejacke deleted the tt_engine branch July 21, 2025 15:48
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.

2 participants