Skip to content

Conversation

@vedhav
Copy link
Contributor

@vedhav vedhav commented Feb 20, 2025

Closes #850

@vedhav vedhav added the core label Feb 20, 2025
@vedhav vedhav enabled auto-merge (squash) February 20, 2025 06:13
@vedhav vedhav requested a review from m7pr February 20, 2025 06:17
@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2025

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  ---------------------------------------
R/tm_a_pca.R                    889     889  0.00%    136-1158
R/tm_a_regression.R             777     777  0.00%    175-1057
R/tm_data_table.R               211     211  0.00%    100-359
R/tm_file_viewer.R              173     173  0.00%    47-255
R/tm_front_page.R               144     133  7.64%    77-247
R/tm_g_association.R            346     346  0.00%    156-577
R/tm_g_bivariate.R              690     426  38.26%   328-815, 856, 967, 984, 1002, 1013-1035
R/tm_g_distribution.R          1119    1119  0.00%    153-1419
R/tm_g_response.R               369     369  0.00%    174-622
R/tm_g_scatterplot.R            731     731  0.00%    257-1092
R/tm_g_scatterplotmatrix.R      296     277  6.42%    195-528, 589, 603
R/tm_missing_data.R            1133    1133  0.00%    121-1431
R/tm_outliers.R                1041    1041  0.00%    160-1352
R/tm_t_crosstable.R             261     261  0.00%    160-469
R/tm_variable_browser.R         832     827  0.60%    89-1078, 1116-1299
R/utils.R                       151     135  10.60%   89-274, 304-340, 352-361, 366, 380-399
R/zzz.R                           2       2  0.00%    2-3
TOTAL                          9165    8850  3.44%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: 9a0b6aa

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2025

Unit Tests Summary

  1 files   22 suites   12m 50s ⏱️
144 tests 107 ✅ 37 💤 0 ❌
474 runs  437 ✅ 37 💤 0 ❌

Results for commit 9a0b6aa.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2025

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
shinytest2-tm_outliers 💚 $111.19$ $-1.82$ $0$ $0$ $0$ $0$

Results for commit 50118a1

♻️ This comment has been updated with latest results.

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.

Tested with below. Works as intended

table_decorator <- function(.color1 = "#f9f9f9", .color2 = "#f0f0f0", .var_to_replace = "table") {
  teal_transform_module(
    label = "Table color",
    ui = function(id) {
      selectInput(
        NS(id, "style"),
        "Table Style",
        choices = c("Default", "Color1", "Color2"),
        selected = "Default"
      )
    },
    server = function(id, data) {
      moduleServer(id, function(input, output, session) {
        logger::log_info("🔵 Table row color called to action!", namespace = "teal.modules.general")
        reactive({
          req(data(), input$style)
          logger::log_info("changing the Table row color '{input$style}'", namespace = "teal.modules.general")
          teal.code::eval_code(data(), substitute({
            .var_to_replace <- switch(
              style,
              "Color1" = DT::formatStyle(
                .var_to_replace,
                columns = attr(.var_to_replace$x, "colnames")[-1],
                target = "row",
                backgroundColor = .color1
              ),
              "Color2" = DT::formatStyle(
                .var_to_replace,
                columns = attr(.var_to_replace$x, "colnames")[-1],
                target = "row",
                backgroundColor = .color2
              ),
              .var_to_replace
            )
          }, env = list(
            style = input$style,
            .var_to_replace = as.name(.var_to_replace),
            .color1 = .color1,
            .color2 = .color2
          )))
        })
      })
    }
  )
}


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

app <- init(
  data = data,
  modules = modules(
    tm_missing_data(
      parent_dataname = "mtcars", 
      decorators = list(table = table_decorator(.var_to_replace = "table"))
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

image

@vedhav vedhav disabled auto-merge February 20, 2025 13:26
@vedhav vedhav enabled auto-merge (squash) February 20, 2025 13:26
@vedhav vedhav merged commit 7719735 into main Feb 20, 2025
27 checks passed
@vedhav vedhav deleted the 850-fix-tm_missing_data-decorators@main branch February 20, 2025 17:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 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]: Decorators does not work for tm_missing_data's output table

3 participants