【问题标题】:R Plotly and shiny : Cstack error, but no error in viewer paneR Plotly 和闪亮:Cstack 错误,但在查看器窗格中没有错误
【发布时间】:2017-06-08 05:16:43
【问题描述】:

我试图在一个闪亮的应用程序中绘制一个不那么大的data.frame,它有 20 列和 10000 行,plot_ly。我收到超出 Cstack 使用量的错误:

Error : C stack usage  11550256 is too close to the limit

Cstack_info()
  size    current  direction eval_depth 
7969177      15056          1          2 

但是,该函数在 Rstudio 源代码窗格中正常工作,并在查看器窗格中呈现。 谁能解释发生了什么并就如何解决此错误提供建议?

提前致谢!


这里最小的工作和不工作的例子:

library(shiny)
library(plotly)
library(reshape2)
library(viridis)

## create data.frame

m <- matrix(rnorm(200000, 100, 10), ncol = 20)
dim(m)
rownames(m) <- paste0("A", "_", 1:nrow(m))
colnames(m) <- paste0("Sample", "_", 1:ncol(m))

## Plotting in the viewer pane -> works fine

y <- melt(m)
y <- group_by(y, Var2)

p <-
  plot_ly(
    y,
    x = ~ Var2,
    y = ~ value,
    color = ~ Var2,
    type = "box",
    showlegend = F,
    colors = viridis(ncol(m))
  )

print(p)


## Not working in shiny

ui <- fluidPage(plotlyOutput("plot"))

server <- function(input, output, session) {
  output$plot <- renderPlotly({
    y <- melt(m)
    y <- group_by(y, Var2)

    p <-
      plot_ly(
        y,
        x = ~ Var2,
        y = ~ value,
        color = ~ Var2,
        type = "box",
        showlegend = F,
        colors = viridis(ncol(m))
      )

    print(p)
  })

}

shinyApp(ui, server)

【问题讨论】:

  • 我无法在 windows 7 / R 3.3.2 上使用最新的 CRAN 版本的闪亮和情节复制
  • 我正在 UbuntuMate 16.04 工作站上使用 R 3.2.3 开发 Rstudio-server。
  • 我看到同样的问题,运行 R 3.4.1、Shiny 1.2.0、Plotly 4.8.0。我在使用不同的数据集时遇到了类似的问题,正在寻找解决方案。

标签: r shiny plotly boxplot rstudio-server


【解决方案1】:

看起来这个问题已经有一段时间没有得到关注了,似乎也没有得到解决。我可以使用上面的示例进行重现,发现如果观察值小于 173,300 它将起作用,但在观察的数量之上,我得到相同的“错误:C 堆栈使用 xxx 太接近限制”。 也许OP能够解决?如果是这样,请发布更新。谢谢

> runApp('ShinyApps/test')

Listening on http://127.0.0.1:3833
SEND {"config": 
{"workerId":"","sessionId":"252a5c03dce4dc01503a7941b18395e4","user":null}}
RECV {"method":"init","data": {".clientdata_output_plot_width":930,".clientdata_output_plot_height":400,".clientdata_output_plot_hidden":false,".clientdata_pixelratio":1,".clientdata_url_protocol":"http:",".clientdata_url_hostname":"ilscha03-hpen-01.uscc.com",".clientdata_url_port":"8787",".clientdata_url_pathname":"/p/3833/",".clientdata_url_search":"",".clientdata_url_hash_initial":"",".clientdata_url_hash":"",".clientdata_singletons":"",".clientdata_allowDataUriScheme":true}}
SEND {"busy":"busy"}
SEND {"recalculating":{"name":"plot","status":"recalculating"}}
SEND {"recalculating":{"name":"plot","status":"recalculated"}}
SEND {"busy":"idle"}
Error: C stack usage  9961999 is too close to the limit

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)

Matrix products: default
BLAS: /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so

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       

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

other attached packages:
 [1] viridis_0.5.1        viridisLite_0.3.0    reshape2_1.4.3       bindrcpp_0.2.2       plotly_4.8.0         DT_0.5.1             lubridate_1.6.0     
 [8] DBI_1.0.0            RODBC_1.3-15         sparklyr_0.9.4       dplyr_0.7.8          purrr_0.2.5          readr_1.2.1          tidyr_0.8.2         
[15] tibble_1.4.2         ggplot2_3.1.0        tidyverse_1.1.1      stringr_1.3.1        shinydashboard_0.7.1 shinyjs_1.0          shiny_1.2.0         

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        lattice_0.20-38   forge_0.1.0       assertthat_0.2.0  rprojroot_1.3-2   digest_0.6.18     mime_0.6          R6_2.3.0         
 [9] cellranger_1.1.0  plyr_1.8.4        backports_1.1.2   httr_1.3.1        pillar_1.3.0      rlang_0.3.0.1     lazyeval_0.2.1    readxl_1.1.0     
[17] rstudioapi_0.8    data.table_1.11.8 config_0.3        r2d3_0.2.2        htmlwidgets_1.3   munsell_0.5.0     broom_0.5.1       compiler_3.4.1   
[25] httpuv_1.4.5      modelr_0.1.2      pkgconfig_2.0.2   base64enc_0.1-3   htmltools_0.3.6   openssl_1.1       tidyselect_0.2.5  gridExtra_2.3    
[33] crayon_1.3.4      dbplyr_1.2.2      withr_2.1.2.9000  later_0.7.5       grid_3.4.1        nlme_3.1-137      jsonlite_1.5      xtable_1.8-3     
[41] gtable_0.2.0      magrittr_1.5      scales_1.0.0      stringi_1.2.4     promises_1.0.1    xml2_1.2.0        generics_0.0.2    tools_3.4.1      
[49] forcats_0.3.0     glue_1.3.0        crosstalk_1.0.0   hms_0.4.2         parallel_3.4.1    rsconnect_0.8.12  yaml_2.2.0        colorspace_1.3-2 
[57] rvest_0.3.2       bindr_0.1.1       haven_2.0.0      
> 

【讨论】:

  • 嗨@JeffKraus,看来这是一种错误。使用 R 3.4.4、shiny 1.2.0、plotly 4.8.0、reshape2 1.4.3 和 viridis 0.5.1,问题不再存在。我从闪亮的代码中删除了print(p),因为它在查看器窗格中显示了绘图。也许这对你有帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-16
  • 2021-01-09
  • 2015-12-02
  • 1970-01-01
  • 2016-08-17
  • 2014-10-08
相关资源
最近更新 更多