Skip to content

[Bug]: New Teal package causes issues that were not there with previous package when assigning a label using attr and a special character #273

@jenko1979

Description

@jenko1979

What happened?

The code below does not work in the new version of Teal but works fine with the old version. I think it is to do with the special apostrophe in the label

data <- teal_data()
data <- within(data, {
  ADSL <- tmc_ex_adsl
  ADSL$EOSDY[1] <- NA_integer_
  attr(ADSL$EOSDY, "label") <-"label’s like this cause downstream, issues"
  attr(ADSL$ARM, "label") <-"This label is OK"
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

ADSL <- data[["ADSL"]]

app <- init(
  data = data,
  modules = modules(
    tm_t_summary(
      label = "Demographic Table",
      dataname = "ADSL",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      add_total = TRUE,
      summarize_vars = choices_selected(
        c("SEX", "RACE", "BMRKR2", "EOSDY", "DCSREAS", "AGE"),
        c("SEX", "RACE")
      ),
      useNA = "ifany"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

I re-iterate, switch to Teal package v0.16.0 and this code works fine

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   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] 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                     DT_0.33                           openxlsx_4.2.8                    fs_1.6.5                         
 [5] stringr_1.5.1                     tidyr_1.3.1                       haven_2.5.4                       dplyr_1.1.4                      
 [9] tibble_3.2.1                      teal.reporter_0.5.0               httr2_1.1.0                       junco_0.1.1                      
[13] teal.modules.clinical.junco_0.1.9 teal.modules.general_0.5.0        ggmosaic_0.3.3                    ggplot2_3.5.1                    
[17] teal.modules.clinical_0.11.1      tern_0.9.9                        rtables_0.6.13                    magrittr_2.0.3                   
[21] formatters_0.5.11                 teal.transform_0.7.0              teal_1.0.0                        teal.slice_0.7.0                 
[25] shiny_1.10.0                      teal.data_0.8.0                   teal.code_0.7.0                   teal.widgets_0.5.0               

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3    rstudioapi_0.17.1     jsonlite_2.0.0        nestcolor_0.1.3       TH.data_1.1-3         estimability_1.5.1   
  [7] farver_2.1.2          rmarkdown_2.29        geepack_1.3.12        vctrs_0.6.5           memoise_2.0.1         htmltools_0.5.8.1    
 [13] broom_1.0.7           cellranger_1.1.0      gridGraphics_0.5-1    sass_0.4.9            huxtable_5.5.7        bslib_0.9.0          
 [19] 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             
 [31] fastmap_1.2.0         rbibutils_2.3         rlistings_0.2.12      digest_0.6.37         patchwork_1.3.0       shinycssloaders_1.1.0
 [37] pkgload_1.4.0         crosstalk_1.2.1       httr_1.4.7            compiler_4.4.1        withr_3.0.2           backports_1.5.0      
 [43] bsicons_0.1.2         logger_0.4.0          MASS_7.3-61           rappdirs_0.3.3        tools_4.4.1           zip_2.3.2            
 [49] httpuv_1.6.15         shinyvalidate_0.1.3   glue_1.8.0            nlme_3.1-166          promises_1.3.2        grid_4.4.1           
 [55] rsconnect_1.3.4       checkmate_2.3.2       generics_0.1.3        tidytlg_0.1.5         gtable_0.3.6          tzdb_0.4.0           
 [61] shinyBS_0.61.1        data.table_1.17.0     hms_1.1.3             ggrepel_0.9.6         pillar_1.10.1         yulab.utils_0.2.0    
 [67] later_1.4.1           splines_4.4.1         tern.gee_0.1.5        lattice_0.22-6        renv_1.0.7            survival_3.8-3       
 [73] tidyselect_1.2.1      knitr_1.49            teal.logger_0.4.0     xfun_0.53             stringi_1.8.4         lazyeval_0.2.2       
 [79] yaml_2.3.10           shinyWidgets_0.9.0    evaluate_1.0.3        codetools_0.2-20      ggplotify_0.1.2       cli_3.6.4            
 [85] xtable_1.8-4          Rdpack_2.6.2          jquerylib_0.1.4       Rcpp_1.0.14           readxl_1.4.3          png_0.1-8            
 [91] readr_2.1.5           assertthat_0.2.1      viridisLite_0.4.2     mvtnorm_1.3-3         scales_1.4.0          purrr_1.0.4          
 [97] crayon_1.5.3          rlang_1.1.5           cowplot_1.1.3         multcomp_1.4-28       shinyjs_2.1.0

Relevant log output

Error in UseMethod("join_keys<-", x) : 
  no applicable method for 'join_keys<-' applied to an object of class "c('qenv.error', 'try-error', 'simpleError', 'error', 'condition')"

From investigations we found that it ate the 'a' in the atrr( statement and instead converted it to ttr and then errors. Happens because of the apostrophe in the label previous

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

No one assigned

    Labels

    bugSomething isn't workingcore

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions