Skip to content
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

introduce decorators for tm_t_crosstable #806

Merged

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented Nov 20, 2024

Part of insightsengineering/teal#1370

Working Example
devtools::load_all("../teal")
devtools::load_all(".")


split_by_decorator <- teal_transform_module(
  label = "Footnote",
  ui = function(id) shiny::textInput(
    shiny::NS(id, "text"), "Insert row", "Hello World!" 
  ),
  server = function(id, data) {
    moduleServer(id, function(input, output, session) {
      logger::log_info("🟢 Text called to action!", namespace = "teal.modules.general")
      reactive(
        within(
          data(),
          {
              table <- table %>% insert_rrow(rrow(text))
          },
          text = input$text
        )
      )
    })
  }
)

# CDISC data example
data <- teal_data()
data <- within(data, {
  ADSL <- rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_t_crosstable(
      label = "Cross Table",
      x = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]], subset = function(data) {
            idx <- !vapply(data, inherits, logical(1), c("Date", "POSIXct", "POSIXlt"))
            return(names(data)[idx])
          }),
          selected = "COUNTRY",
          multiple = TRUE,
          ordered = TRUE,
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]], subset = function(data) {
            idx <- vapply(data, is.factor, logical(1))
            return(names(data)[idx])
          }),
          selected = "SEX",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      decorators = list(split_by_decorator)
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

@m7pr m7pr added the core label Nov 20, 2024
@m7pr m7pr requested a review from averissimo November 20, 2024 14:54
@m7pr m7pr changed the base branch from main to 1187_decorate_output@main November 20, 2024 14:54
Copy link
Contributor

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  ------------------------------------
R/tm_a_pca.R                    827     827  0.00%    106-1066
R/tm_a_regression.R             808     808  0.00%    160-1071
R/tm_data_table.R               185     185  0.00%    100-339
R/tm_file_viewer.R              173     173  0.00%    47-255
R/tm_front_page.R               133     122  8.27%    73-231
R/tm_g_association.R            330     330  0.00%    134-536
R/tm_g_bivariate.R              672     410  38.99%   301-767, 808, 919, 936, 954, 965-987
R/tm_g_distribution.R          1048    1048  0.00%    125-1311
R/tm_g_response.R               351     351  0.00%    151-575
R/tm_g_scatterplot.R            722     722  0.00%    233-1056
R/tm_g_scatterplotmatrix.R      278     259  6.83%    172-479, 540, 554
R/tm_missing_data.R            1070    1070  0.00%    91-1317
R/tm_outliers.R                 985     985  0.00%    129-1258
R/tm_t_crosstable.R             255     255  0.00%    147-451
R/tm_variable_browser.R         830     825  0.60%    89-1081, 1119-1303
R/utils.R                        99      96  3.03%    84-269
R/zzz.R                           2       2  0.00%    2-3
TOTAL                          8768    8468  3.42%

Diff against main

Filename               Stmts    Miss  Cover
-------------------  -------  ------  --------
R/tm_a_regression.R      +35     +35  +100.00%
R/tm_t_crosstable.R       +4      +4  +100.00%
TOTAL                    +39     +39  -0.02%

Results for commit: 51f6882

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Nov 20, 2024

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
shinytest2-tm_a_pca 💔 $120.63$ $+1.47$ $0$ $0$ $0$ $0$
shinytest2-tm_a_regression 💔 $54.97$ $+11.88$ $0$ $0$ $0$ $0$
shinytest2-tm_g_bivariate 💔 $74.92$ $+1.38$ $0$ $0$ $0$ $0$
shinytest2-tm_g_scatterplot 💔 $74.74$ $+1.20$ $0$ $0$ $0$ $0$
shinytest2-tm_outliers 💔 $107.55$ $+1.58$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
shinytest2-tm_a_regression 💔 $13.46$ $+5.28$ e2e_tm_a_regression_Plot_type_has_7_specific_choices_changing_choices_does_not_throw_errors.
shinytest2-tm_a_regression 💔 $6.66$ $+2.24$ e2e_tm_a_regression_Plot_type_is_set_properly.
shinytest2-tm_a_regression 💔 $10.10$ $+1.28$ e2e_tm_a_regression_Unchecking_display_outlier_hides_outlier_label_and_definition.

Results for commit 3579bc1

♻️ This comment has been updated with latest results.

R/tm_t_crosstable.R Outdated Show resolved Hide resolved
R/tm_t_crosstable.R Outdated Show resolved Hide resolved
m7pr and others added 2 commits November 21, 2024 15:15
Co-authored-by: André Veríssimo <[email protected]>
Signed-off-by: Marcin <[email protected]>
Co-authored-by: André Veríssimo <[email protected]>
Signed-off-by: Marcin <[email protected]>
@m7pr m7pr requested a review from averissimo November 21, 2024 14:17
@m7pr
Copy link
Contributor Author

m7pr commented Nov 21, 2024

Thanks @averissimo for the review. I accepted changes and run the example app again. Now everything is perfect. Asked for another round of the reviews

Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

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

Let's goooooo!!

@m7pr m7pr merged commit 824efcf into 1187_decorate_output@main Nov 22, 2024
1 check passed
@m7pr m7pr deleted the tm_crosstable@1187_decorate_output@main branch November 22, 2024 10:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2024
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.

2 participants