Skip to content

Conversation

@vedhav
Copy link
Contributor

@vedhav vedhav commented Feb 20, 2025

Closes #851

@vedhav vedhav added the core label Feb 20, 2025
@vedhav vedhav enabled auto-merge (squash) February 20, 2025 06:12
@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                    888     888  0.00%    136-1157
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                          9164    8849  3.44%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  --------
R/tm_outliers.R       -3      -3  +100.00%
TOTAL                 -3      -3  +0.00%

Results for commit: 2ff03e1

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   13m 3s ⏱️
144 tests 107 ✅ 37 💤 0 ❌
474 runs  437 ✅ 37 💤 0 ❌

Results for commit 2ff03e1.

♻️ 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$
examples 💚 $4.89$ $-4.30$ $-1$ $+37$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
examples 💚 $1.71$ $-1.62$ example_add_facet_labels.Rd

Results for commit 1e51531

♻️ 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.

Decorator code is visible in the Show R Code

image

and the decorator is applied

image

tested with

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


# general data example
data <- teal_data()
data <- within(data, {
  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_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
          )
        )
      ),
      decorators = list(table = table_decorator(.var_to_replace = "table"))
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

      

@vedhav vedhav merged commit b44ae04 into main Feb 20, 2025
29 checks passed
@vedhav vedhav deleted the 851-fix-tm_outliers-decorators@main branch February 20, 2025 12:00
@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_outliers's output table

3 participants