Skip to content

Conversation

@averissimo
Copy link
Contributor

Pull Request

Changes description

  • Use of rtables::df_to_tt to produce report tables (that are decoratable)
  • Update decorators documentation to reflect
  • Minor code improvements that are marginally related (better variable name to separate data (raw data frame) from table (rtable or DT))

@averissimo averissimo changed the title Fixes when module trie Fixes failing "Add to Report" for modules that have DT table visualization Jul 25, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 25, 2025

Unit Tests Summary

  1 files  22 suites   1s ⏱️
142 tests 29 ✅ 113 💤 0 ❌
180 runs  67 ✅ 113 💤 0 ❌

Results for commit 98d2f17.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 25, 2025

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  ---------------------------------------
R/tm_a_pca.R                    889     889  0.00%    139-1161
R/tm_a_regression.R             771     771  0.00%    178-1054
R/tm_data_table.R               200     200  0.00%    100-348
R/tm_file_viewer.R              172     172  0.00%    47-254
R/tm_front_page.R               143     132  7.69%    77-246
R/tm_g_association.R            345     345  0.00%    159-579
R/tm_g_bivariate.R              699     435  37.77%   331-827, 868, 979, 996, 1014, 1025-1047
R/tm_g_distribution.R          1118    1118  0.00%    152-1419
R/tm_g_response.R               370     370  0.00%    177-626
R/tm_g_scatterplot.R            735     735  0.00%    260-1099
R/tm_g_scatterplotmatrix.R      298     279  6.38%    198-533, 594, 608
R/tm_missing_data.R            1119    1119  0.00%    122-1417
R/tm_outliers.R                1055    1055  0.00%    161-1372
R/tm_t_crosstable.R             286     286  0.00%    175-519
R/tm_variable_browser.R         803     798  0.62%    89-1046, 1084-1267
R/utils.R                       144     128  11.11%   87-249, 279-315, 327-336, 341, 355-374
R/zzz.R                           2       2  0.00%    2-3
TOTAL                          9149    8834  3.44%

Diff against main

Filename                 Stmts    Miss  Cover
---------------------  -------  ------  --------
R/tm_g_distribution.R      -10     -10  +100.00%
R/tm_outliers.R             -7      -7  +100.00%
TOTAL                      -17     -17  +0.01%

Results for commit: 98d2f17

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@averissimo averissimo requested a review from a team August 4, 2025 13:17
@vedhav vedhav self-assigned this Aug 4, 2025
Signed-off-by: André Veríssimo <[email protected]>
@m7pr m7pr requested a review from Copilot August 5, 2025 11:05
@m7pr m7pr self-assigned this Aug 5, 2025
Copy link

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 fixes the "Add to Report" functionality for modules that use DT table visualizations by migrating from DT datatables to rtables format. The key issue was that modules using interactive DataTables couldn't properly export decorated tables to reports.

  • Replaces DT::datatable() with rtables::df_to_tt() for creating decoratable table objects
  • Updates documentation to clarify that decorated tables appear in reports while interactive DataTables remain in the module UI
  • Improves variable naming to distinguish between raw data frames and table objects

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
R/tm_outliers.R Migrates table creation from DT to rtables, improves variable naming from summary_table_pre to summary_data_pre
R/tm_missing_data.R Converts table generation to use rtables format for decorator compatibility
R/tm_g_distribution.R Updates both summary and test tables to use rtables, adds proper empty table handling
R/tm_g_bivariate.R Minor cleanup removing unused library import
man/*.Rd Updates documentation to reflect rtables usage and clarify decorator behavior
NEWS.md Documents the bug fix for "Add to Report" functionality

@m7pr
Copy link
Contributor

m7pr commented Aug 5, 2025

Tested with

devtools::load_all("teal.code")
devtools::load_all("teal.data")
devtools::load_all("teal.transform")
devtools::load_all("teal.logger")
devtools::load_all("teal.reporter")
devtools::load_all("teal.widgets")
devtools::load_all("teal")
devtools::load_all("teal.modules.general")

data <- teal_data()
data <- within(data, {
  require(nestcolor)

  add_nas <- function(x) {
    x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA
    x
  }

  iris <- iris
  mtcars <- mtcars

  iris[] <- lapply(iris, add_nas)
  mtcars[] <- lapply(mtcars, add_nas)
  mtcars[["cyl"]] <- as.factor(mtcars[["cyl"]])
  mtcars[["gear"]] <- as.factor(mtcars[["gear"]])

  CO2 <- CO2
  CO2[["primary_key"]] <- seq_len(nrow(CO2))
})

join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key"))

vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")))

app <- init(
  data = data,
  modules = modules(
    tm_missing_data(parent_dataname = "mtcars"),
    tm_g_distribution(
      dist_var = data_extract_spec(
        dataname = "iris",
        select = select_spec(variable_choices("iris"), "Petal.Length")
      )
    ),
    tm_outliers(
      outlier_var = list(
        data_extract_spec(
          dataname = "CO2",
          select = select_spec(
            label = "Select variable:",
            choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
            selected = "uptake",
            multiple = FALSE,
            fixed = FALSE
          )
        )
      ),
      categorical_var = list(
        data_extract_spec(
          dataname = "CO2",
          filter = filter_spec(
            vars = vars,
            choices = value_choices(data[["CO2"]], vars$selected),
            selected = value_choices(data[["CO2"]], vars$selected),
            multiple = TRUE
          )
        )
      )
    )
  )
)

shinyApp(app$ui, app$server)

and I was able to add card to the report in all 3 modules

Recording.2025-08-05.131354.mp4

@averissimo averissimo requested a review from m7pr August 5, 2025 12:20
Copy link
Contributor

@m7pr m7pr left a comment

Choose a reason for hiding this comment

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

retested and lgtm!

@averissimo averissimo requested a review from m7pr August 8, 2025 12:06
Copy link
Contributor

@vedhav vedhav left a comment

Choose a reason for hiding this comment

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

LGTM! Tested the three modules and report was added successfully. And verified the NEWS and docs.
image

@averissimo averissimo merged commit ce590d2 into main Aug 8, 2025
29 checks passed
@averissimo averissimo deleted the 899-report_missing_data branch August 8, 2025 12:34
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't add report that have DataTable tables [Bug]: Can't add a card to report from tm_g_distribution

4 participants