R 4.3.0升级后Shiny应用点击地图触发shinyalert报错求助
R 4.3.0升级后Shiny应用中shinyalert弹窗触发
&&: 'length = 3'逻辑错误 问题背景
我正在开发一款Shiny应用,支持用户在Leaflet地图上标记点位并添加标签,最终导出为.csv文件。该应用原本基于旧版R及依赖包运行正常,但在将R升级至4.3.0并同步更新所有依赖包后,点击地图注册GPS点位时出现逻辑错误。
错误信息
点击地图后触发以下错误:
Warning: Error in &&: 'length = 3' in coercion to 'logical(1)' 3: runApp 2: print.shiny.appobj 1: <Anonymous>
排查过程
经测试验证,错误仅在调用包含三个元素的shinyalert弹窗时触发(错误中的length = 3对应弹窗内的三个组件):
- 移除弹窗中的HTML行后,错误变为
length = 2 - 完全删除以下核心功能代码块后,错误消失,但这段代码是应用必需的:
observeEvent(input$map_click, { shinyalert(html = TRUE, showConfirmButton = F, text = tagList(HTML(paste0("Proposition :<br>")), textInput("prop", ""), actionButton("enter", "Valider"))) })
我怀疑问题出在shinyalert包内部的条件判断(与地图点击状态的if语句相关),且可能和R 4.3.0的Base R更新有关,但未找到受影响包的官方列表,不清楚错误的具体成因及修复方法,寻求帮助。
会话信息
> sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045) Matrix products: default locale: [1] LC_COLLATE=English_United Kingdom.utf8 LC_CTYPE=English_United Kingdom.utf8 [3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.utf8 time zone: Europe/London tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] sf_1.0-12 dplyr_1.1.2 rio_0.5.29 here_1.0.1 pacman_0.5.1 [6] leaflet_2.1.2 DT_0.28 shinyalert_3.0.0 shiny_1.7.4 loaded via a namespace (and not attached): [1] xfun_0.39 bslib_0.4.2 htmlwidgets_1.6.2 vctrs_0.6.2 [5] tools_4.3.0 crosstalk_1.2.0 generics_0.1.3 curl_5.0.0 [9] tibble_3.2.1 proxy_0.4-27 fansi_1.0.4 pkgconfig_2.0.3 [13] KernSmooth_2.23-20 data.table_1.14.8 checkmate_2.2.0 readxl_1.4.2 [17] uuid_1.1-0 lifecycle_1.0.3 compiler_4.3.0 fontawesome_0.5.1 [21] httpuv_1.6.9 htmltools_0.5.5 class_7.3-21 sass_0.4.6 [25] yaml_2.3.7 later_1.3.0 pillar_1.9.0 crayon_1.5.2 [29] jquerylib_0.1.4 ellipsis_0.3.2 classInt_0.4-9 cachem_1.0.8 [33] mime_0.12 zip_2.3.0 tidyselect_1.2.0 shinydisconnect_0.1.0 [37] digest_0.6.31 stringi_1.7.12 colourpicker_1.2.0 forcats_1.0.0 [41] rprojroot_2.0.3 fastmap_1.1.1 grid_4.3.0 cli_3.6.1 [45] magrittr_2.0.3 utf8_1.2.3 e1071_1.7-13 foreign_0.8-84 [49] withr_2.5.0 promises_1.2.0.1 backports_1.4.1 cellranger_1.1.0 [53] hms_1.1.3 openxlsx_4.2.5.2 memoise_2.0.1 knitr_1.42 [57] haven_2.5.2 miniUI_0.1.1.1 rlang_1.1.0 Rcpp_1.0.10 [61] xtable_1.8-4 glue_1.6.2 DBI_1.1.3 rstudioapi_0.14 [65] jsonlite_1.8.4 R6_2.5.1 units_0.8-1
内容的提问来源于stack exchange,提问作者Amy M
相关产品推荐
相关产品推荐

