-
-
Notifications
You must be signed in to change notification settings - Fork 15
Fixes failing "Add to Report" for modules that have DT table visualization
#900
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
DT table visualization
Unit Tests Summary 1 files 22 suites 1s ⏱️ Results for commit 98d2f17. ♻️ This comment has been updated with latest results. |
Code Coverage SummaryDiff against mainResults for commit: 98d2f17 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Signed-off-by: André Veríssimo <[email protected]>
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 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()withrtables::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 |
|
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 |
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.
retested and lgtm!
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
DataTabletables #899Changes description
rtables::df_to_ttto produce report tables (that are decoratable)data(raw data frame) fromtable(rtable or DT))