insightsengineering / insightsengineering/teal.goshawk

[Bug]: tm_g_gh_spaghettiplot crashes without color_comb set

Open
#367 1 comment 0 reactions 0 assignees View on GitHub
bug core
Dominant language
R
Stars
3
Forks
3
Avg merge
2d 6h
Merged PRs (30d)
11

Description

### What happened?

The code below crashes the teal app and throws an error when `color_comb = "#39ff14"` is not set and group statistics are set to "Mean" or "Median".

```
tm_g_gh_spaghettiplot(
label = "ADLB: Spaghetti Plot",
dataname = "ADLB",
idvar = "USUBJID",
param_var = "PARAMCD",
param_var_label = "PARAM",
color_comb = "#39ff14",
param = choices_selected(value_choices(adam.data$ADLB, "PARAMCD", "PARAM"), selected = "ALT"),
xaxis_var = choices_selected(variable_choices(adam.data$ADLB, c("AVISIT", "AVISITN")), selected = "AVISIT"),
xaxis_var_level = levels(adam.data$ADLB$AVISIT),
yaxis_var = choices_selected(variable_choices(adam.data$ADLB, c("AVAL", "BASE", "CHG", "PCHG")), selected = "AVAL"),
trt_group = choices_selected(variable_choices(adam.data$ADSL, c("ARM")), selected = "ARM")
)
```

### sessionInfo()

```R
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.7

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] teal.reporter_0.5.0.9004 teal.widgets_0.5.0 teal.goshawk_0.4.0.9002 goshawk_0.1.19.9001
[5] dplyr_1.1.4 teal.modules.clinical_0.11.1 tern_0.9.9 rtables_0.6.13
[9] magrittr_2.0.3 formatters_0.5.11 teal.modules.general_0.5.0 teal.transform_0.7.0
[13] ggmosaic_0.3.3 ggplot2_3.5.2 teal_1.0.0.9003 teal.slice_0.7.0
[17] teal.data_0.8.0 teal.code_0.7.0 shiny_1.10.0
[21] arrow_19.0.1.1

loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 viridisLite_0.4.2 farver_2.1.2 fastmap_1.2.0 lazyeval_0.2.2 promises_1.3.2 digest_0.6.37
[8] mime_0.12 lifecycle_1.0.4 survival_3.8-3 compiler_4.4.1 rlang_1.1.6 bsicons_0.1.2 tools_4.4.1
[15] utf8_1.2.5 data.table_1.17.0 htmlwidgets_1.6.4 bit_4.5.0.1 here_1.0.1 RColorBrewer_1.1-3 pkgload_1.4.0
[22] rsconnect_1.3.4 withr_3.0.2 purrr_1.0.4 grid_4.4.1 teal.logger_0.4.0 xtable_1.8-4 nestcolor_0.1.3
[29] scales_1.4.0 gtools_3.9.5 cli_3.6.5 crayon_1.5.3 generics_0.1.3 rstudioapi_0.16.0 httr_1.4.7
[36] tzdb_0.4.0 splines_4.4.1 assertthat_0.2.1 parallel_4.4.1 formatR_1.14 vctrs_0.6.5 Matrix_1.7-0
[43] jsonlite_2.0.0 hms_1.1.3 bit64_4.6.0-1 ggrepel_0.9.6 plotly_4.10.4 tidyr_1.3.1 glue_1.8.0
[50] stringi_1.8.4 gtable_0.3.6 mcr_1.3.3.1 later_1.4.1 tibble_3.2.1 logger_0.4.1 pillar_1.10.2
[57] htmltools_0.5.8.1 R6_2.6.1 Rdpack_2.6.4 rprojroot_2.0.4 lattice_0.22-6 haven_2.5.4 readr_2.1.5
[64] rbibutils_2.3 backports_1.5.0 broom_1.0.8 httpuv_1.6.15 robslopes_1.1.3 Rcpp_1.0.14 checkmate_2.3.2
[71] forcats_1.0.0 pkgconfig_2.0.3
```

### Relevant log output

```R
Warning: Error in ggplot2::geom_line: Problem while setting up geom aesthetics.
ℹ Error occurred in the 3rd layer.
Caused by error in `check_aesthetics()`:
! Aesthetics must be either length 1 or the same as the data (3975).
✖ Fix the following mappings: `colour`.
184:
183: stop
182: r
181: eventReactiveValueFunc
129: plot_q
128:
108: plot_r
101: renderUI
100: func
87: renderFunc
86: output$teal-teal_modules-nav-lab-adlb__spaghetti_plot-module-plot-plot_out_main
1: runApp
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.