使用mapdeck R包fill_colour参数时RStudio会话崩溃,如何排查?
问题
使用mapdeck包的fill_colour参数时,RStudio会话会直接崩溃。例如运行官方示例代码:
library(mapdeck) library(sf) sf <- spatialwidget::widget_melbourne mapdeck() %>% add_polygon( data = sf , fill_colour = "SA2_NAME" )
系统提示「R Session Aborted」并崩溃,但移除fill_colour参数后,以下代码可正常生成地图:
library(mapdeck) library(sf) sf <- spatialwidget::widget_melbourne mapdeck() %>% add_polygon( data = sf )
查看RStudio日志未找到崩溃相关信息,当前会话信息如下:
sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044) Matrix products: default locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C [5] LC_TIME=English_United States.utf8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] units_0.8-0 dplyr_1.0.9 jsonify_1.2.1 RColorBrewer_1.1-3 sf_1.0-8 mapdeck_0.3.4 stringr_1.4.0 arrow_8.0.0 [9] webshot2_0.1.0 ggplot2_3.3.6 glue_1.6.2 magrittr_2.0.3 flextable_0.7.0 data.table_1.14.2 lubridate_1.8.0 loaded via a namespace (and not attached): [1] Rcpp_1.0.8.3 class_7.3-20 ps_1.7.0 assertthat_0.2.1 digest_0.6.29 utf8_1.2.2 R6_2.5.1 evaluate_0.15 [9] e1071_1.7-9 pillar_1.7.0 gdtools_0.2.4 rlang_1.0.2 uuid_1.1-0 rmarkdown_2.14 htmlwidgets_1.5.4 bit_4.0.4 [17] munsell_0.5.0 proxy_0.4-26 compiler_4.2.0 xfun_0.31 pkgconfig_2.0.3 systemfonts_1.0.4 base64enc_0.1-3 htmltools_0.5.2 [25] spatialwidget_0.2.3 websocket_1.4.1 tidyselect_1.1.2 tibble_3.1.7 fansi_1.0.3 crayon_1.5.1 withr_2.5.0 later_1.3.0 [33] grid_4.2.0 jsonlite_1.8.0 gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.2 scales_1.2.0 KernSmooth_2.23-20 zip_2.2.0 [41] cli_3.3.0 stringi_1.7.6 promises_1.2.0.1 xml2_1.3.3 ellipsis_0.3.2 generics_0.1.2 vctrs_0.4.1 tools_4.2.0 [49] bit64_4.0.5 officer_0.4.2 purrr_0.3.4 processx_3.5.3 fastmap_1.1.0 yaml_2.3.5 chromote_0.1.0 colorspace_2.0-3 [57] classInt_0.4-3 knitr_1.39
解决建议
- 重装核心依赖包:卸载并重装
mapdeck和spatialwidget,修复可能的包损坏或版本兼容问题:remove.packages(c("mapdeck", "spatialwidget")) install.packages(c("mapdeck", "spatialwidget")) - 升级R版本:当前使用的R 4.2.0版本较旧,部分包的功能在旧版R上可能存在兼容性bug,建议升级到最新稳定版R后重试。
- 测试干净会话:重启RStudio后仅加载
mapdeck和sf两个包,排除其他包的干扰:library(mapdeck) library(sf) sf <- spatialwidget::widget_melbourne mapdeck() %>% add_polygon(data = sf, fill_colour = "SA2_NAME") - 检查系统依赖:Windows环境下,mapdeck依赖Visual C++ Redistributable运行库,确保你的系统已安装最新版本。
- 尝试开发版包:如果稳定版无效,安装mapdeck的开发版,可能已修复崩溃问题:
remotes::install_github("symbolixau/mapdeck")
内容的提问来源于stack exchange,提问作者Dean MacGregor
相关产品推荐
相关产品推荐

