Skip to content

tm_t_events_by_grade - bug in grading_groups when using >= #1377

@jenko1979

Description

@jenko1979

What happened?

The following code (mostly taken from the example you have documented aside from me adding in the grading_groups) works fine.

library(dplyr)
data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  .lbls_adae <- col_labels(tmc_ex_adae)
  ADAE <- tmc_ex_adae %>%
    mutate_if(is.character, as.factor) #' be certain of having factors
  col_labels(ADAE) <- .lbls_adae
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_events_by_grade(
      label = "Adverse Events by Grade Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(ADAE, c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      grade = choices_selected(
        choices = variable_choices(ADAE, c("AETOXGR", "AESEV")),
        selected = "AETOXGR"
      ),
      grading_groups = list(`Any Grade (%)` = c("1", "2", "3", "4", "5"), 
                            `Grade 1 (%)` = c("1"), `Grade 2 (%)` = c("2"), `Grade 3 (%)` = c("3"), `Grade 4 (%)` = c("4"), `Grade 5 (%)` = c("5"), `Grade 3-5 (%)` = c("3", "4", "5"))
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

If you run the above code and then check the "Display grade groupings in nested columns" box, we see the desired output.

However, when i switch to use Grade >= 3 instead of Grade 3-5 and then check the "Display grade groupings in nested columns" box, the app does not run. I think it does not like the >= in some cases?

Non-working code:

library(dplyr)
data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  .lbls_adae <- col_labels(tmc_ex_adae)
  ADAE <- tmc_ex_adae %>%
    mutate_if(is.character, as.factor) #' be certain of having factors
  col_labels(ADAE) <- .lbls_adae
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]
ADAE <- data[["ADAE"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_events_by_grade(
      label = "Adverse Events by Grade Table",
      dataname = "ADAE",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      llt = choices_selected(
        choices = variable_choices(ADAE, c("AETERM", "AEDECOD")),
        selected = c("AEDECOD")
      ),
      hlt = choices_selected(
        choices = variable_choices(ADAE, c("AEBODSYS", "AESOC")),
        selected = "AEBODSYS"
      ),
      grade = choices_selected(
        choices = variable_choices(ADAE, c("AETOXGR", "AESEV")),
        selected = "AETOXGR"
      ),
      grading_groups = list(`Any Grade (%)` = c("1", "2", "3", "4", "5"), 
                            `Grade 1 (%)` = c("1"), `Grade 2 (%)` = c("2"), `Grade 3 (%)` = c("3"), `Grade 4 (%)` = c("4"), `Grade 5 (%)` = c("5"), `Grade >=3 (%)` = c("3", "4", "5"))
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

sessionInfo()

R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Rocky Linux 8.10 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.15.so;  LAPACK version 3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8      
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] forcats_1.0.0                   teal.widgets_0.4.3              DT_0.33                         openxlsx_4.2.8                  fs_1.6.5                       
 [6] stringr_1.5.1                   tidyr_1.3.1                     haven_2.5.4                     dplyr_1.1.4                     tibble_3.2.1                   
[11] teal.reporter_0.4.0             httr2_1.1.0                     junco_0.0.1                     tidytlg_0.1.5                   teal.modules.clinical.jnj_0.1.3
[16] teal.modules.general_0.4.0      ggmosaic_0.3.3                  ggplot2_3.5.1                   teal.modules.clinical_0.10.0    tern_0.9.7                     
[21] rtables_0.6.11                  magrittr_2.0.3                  formatters_0.5.10               teal.transform_0.6.0            teal_0.16.0                    
[26] teal.slice_0.6.0                teal.data_0.7.0                 teal.code_0.6.1                 shiny_1.10.0                   

loaded via a namespace (and not attached):
 [1] rstudioapi_0.17.1     jsonlite_1.9.0        nestcolor_0.1.3       TH.data_1.1-3         estimability_1.5.1    farver_2.1.2          rmarkdown_2.29        geepack_1.3.12       
 [9] vctrs_0.6.5           memoise_2.0.1         askpass_1.2.1         htmltools_0.5.8.1     broom_1.0.7           cellranger_1.1.0      gridGraphics_0.5-1    sass_0.4.9           
[17] huxtable_5.5.7        bslib_0.9.0           htmlwidgets_1.6.4     fontawesome_0.5.3     sandwich_3.1-1        emmeans_1.10.7        plotly_4.10.4         zoo_1.8-13           
[25] cachem_1.1.0          mime_0.12             lifecycle_1.0.4       pkgconfig_2.0.3       Matrix_1.7-1          R6_2.6.1              fastmap_1.2.0         rbibutils_2.3        
[33] digest_0.6.37         colorspace_2.1-1      patchwork_1.3.0       shinycssloaders_1.1.0 crosstalk_1.2.1       httr_1.4.7            compiler_4.4.1        withr_3.0.2          
[41] backports_1.5.0       logger_0.4.0          MASS_7.3-61           rappdirs_0.3.3        tools_4.4.1           zip_2.3.2             httpuv_1.6.15         shinyvalidate_0.1.3  
[49] glue_1.8.0            nlme_3.1-166          promises_1.3.2        grid_4.4.1            checkmate_2.3.2       generics_0.1.3        gtable_0.3.6          tzdb_0.4.0           
[57] data.table_1.17.0     hms_1.1.3             ggrepel_0.9.6         pillar_1.10.1         yulab.utils_0.2.0     later_1.4.1           splines_4.4.1         tern.gee_0.1.5       
[65] lattice_0.22-6        renv_1.0.7            survival_3.7-0        tidyselect_1.2.1      knitr_1.49            teal.logger_0.3.2     xfun_0.51             stringi_1.8.4        
[73] lazyeval_0.2.2        yaml_2.3.10           shinyWidgets_0.9.0    evaluate_1.0.3        codetools_0.2-20      ggplotify_0.1.2       cli_3.6.4             xtable_1.8-4         
[81] Rdpack_2.6.2          munsell_0.5.1         jquerylib_0.1.4       Rcpp_1.0.14           readxl_1.4.3          png_0.1-8             readr_2.1.5           assertthat_0.2.1     
[89] viridisLite_0.4.2     mvtnorm_1.3-3         scales_1.3.0          purrr_1.0.4           crayon_1.5.3          rlang_1.1.5           cowplot_1.1.3         multcomp_1.4-28      
[97] shinyjs_2.1.0

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions