使用 ggplotly() 后 R 会话挂起

R session hangs up after using ggplotly()

提问人:user2955884 提问时间:11/17/2023 最后编辑:user2955884 更新时间:11/17/2023 访问量:13

问:

我的 R 会话(在 RStudio 中)在使用 ggplotly() 后挂起。
为了进行测试,我使用了 ?ggplotly 的示例之一。该示例通常可以正常工作一两次,但 R 会话在多次尝试后挂起(在下面的示例中,第 2 次运行挂断了会话)。我什至无法从 GUI 关闭 RStudio,而必须使用系统监视器应用程序来杀死它。
当我在加载给定项目后运行以下代码时,会出现此问题,而不是 如果我在没有项目的情况下启动 R 会话。但是项目没有加载任何数据或包,所以不知道如何识别问题。
这是我具体做的:

    > ls()
    character(0)
    > search()
     [1] ".GlobalEnv"        "tools:rstudio"     "package:stats"     "package:graphics"  "package:grDevices"
     [6] "package:utils"     "package:datasets"  "package:methods"   "Autoloads"         "package:base"     
    > sessionInfo()
    R version 4.1.2 (2021-11-01)
    Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Pop!_OS 22.04 LTS
    
    Matrix products: default
    BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so
    
    locale:
     [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=es_ES.UTF-8       
     [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=en_US.UTF-8   
     [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
    [10] LC_TELEPHONE=C             LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    loaded via a namespace (and not attached):
     [1] rgl_1.2.1              Rcpp_1.0.11            class_7.3-20           digest_0.6.33         
     [5] kml_2.4.6              R6_2.5.1               plyr_1.8.9             jsonlite_1.8.7        
     [9] magrittr_2.0.3         evaluate_0.22          rlang_1.1.1            longitudinalData_2.4.5
    [13] cli_3.6.1              misc3d_0.9-1           rstudioapi_0.15.0      rmarkdown_2.25        
    [17] tools_4.1.2            htmlwidgets_1.6.2      clv_0.3-2.4            xfun_0.40             
    [21] yaml_2.3.7             fastmap_1.1.1          compiler_4.1.2         base64enc_0.1-3       
    [25] cluster_2.1.2          tcltk_4.1.2            htmltools_0.5.6.1      knitr_1.44            
    
    > library(ggplot2)
    > library(plotly)

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

    last_plot

The following object is masked from ‘package:stats’:

    filter

The following object is masked from ‘package:graphics’:

    layout
    > data(canada.cities, package = "maps")
    > viz <- ggplot(canada.cities, aes(long, lat)) +
    +     borders(regions = "canada") +
    +     coord_equal() +
    +     geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2)
    Warning message:
    In geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2) :
      Ignoring unknown aesthetics: text
    > ggplotly(viz, tooltip = c("text", "size"))
    > 
    > 
    > 
    > 
    > data(canada.cities, package = "maps")
    > viz <- ggplot(canada.cities, aes(long, lat)) +
    +     borders(regions = "canada") +
    +     coord_equal() +
    +     geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2)
    Warning message:
    In geom_point(aes(text = name, size = pop), colour = "red", alpha = 1/2) :
      Ignoring unknown aesthetics: text
    > ggplotly(viz, tooltip = c("text", "size"))
    > 
    > 
r plotly rstudio

评论


答: 暂无答案