Closed donyunardi closed 8 months ago
One possible way to solve this is to wrap all()
on modules$datanames == "all"
datanames <- if (is.null(modules$datanames) || all(modules$datanames == "all")) {
I did this locally and the code can now run. If this finding is correct, let's do a patch release.
What happened?
A bug happened!
Code
```r Sys.setenv(TEAL.LOG_LEVEL = "TRACE") library(teal.logger) library(teal.modules.clinical) ADSL <- teal.modules.clinical::tmc_ex_adsl ADAE <- teal.modules.clinical::tmc_ex_adae ADTTE <- teal.modules.clinical::tmc_ex_adtte app <- init( data = cdisc_data( ADSL = ADSL, ADAE = ADAE, ADTTE = ADTTE ), modules = modules( tm_t_summary( label = "Demographic Table", dataname = "ADSL", arm_var = choices_selected(choices = c("ARM", "ARMCD"), selected = "ARM"), summarize_vars = choices_selected( choices = c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"), selected = c("SEX", "RACE") ) ), tm_t_events( label = "AE Table", dataname = "ADAE", arm_var = choices_selected(choices = c("ARM", "ARMCD"), selected = "ARM"), hlt = choices_selected( choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")), selected = "AEBODSYS" ), llt = choices_selected( choices = variable_choices(ADAE, c("AETERM", "AEDECOD")), selected = c("AEDECOD") ) ), tm_g_km( label = "KM Plot", dataname = "ADTTE", arm_var = choices_selected(choices = c("ARM", "ARMCD", "ACTARMCD"), selected = "ARM"), paramcd = choices_selected(choices = value_choices(ADTTE, "PARAMCD", "PARAM"), selected = "OS"), strata_var = choices_selected(variable_choices(ADSL, c("SEX", "BMRKR2")), NULL), facet_var = choices_selected(variable_choices(ADSL, c("SEX", "BMRKR2")), NULL), plot_height = c(600L, 400L, 5000L), ) ), header = tags$h1("PHUSE US Connect 2024 teal Workshop"), filter = teal_slices( teal_slice("ADSL", "SAFFL", id = "saffl", selected = "Y", fixed = TRUE, anchored = TRUE), teal_slice("ADAE", "AESER", anchored = TRUE), teal_slice("ADAE", id = "aerel", expr = "AEREL == 'Y' & AETOXGR %in% c('3', '4', '5')", title = "Grade 3+ Related Events"), teal_slice("ADSL", "SEX", id = "sex", fixed = TRUE), teal_slice("ADSL", id = "age", expr = "AGE >= 18 & AGE <= 30", title = "Young Adult"), module_specific = TRUE, mapping = list( "Demographic Table" = c("saffl"), "AE Table" = c("saffl", "aerel"), global_filters = c("sex", "age") ), count_type = "all" ) ) shinyApp(app$ui, app$server) ```The above code can't be run when I set
module_specific = TRUE
during filter creation and got this error message:The problem is on this line: https://github.com/insightsengineering/teal/blob/91e000d7094389b41ec87ae5c7d98537182c0085/R/module_teal.R#L189
For
tm_t_events
,modules$datanames
will return vector with length of 2: https://github.com/insightsengineering/teal.modules.clinical/blob/main/R/tm_t_events.R#L568Therefore, the
if
statement will fail becausemodules$datanames
returns "ADSL" and "ADAE".Here's an illustration:
Created on 2024-02-19 with reprex v2.0.2
sessionInfo()
Relevant log output
No response
Code of Conduct
Contribution Guidelines
Security Policy