R Plotly and shiny:Cstack错误,但查看器窗格中没有错误

时间:2017-01-23 16:10:54

标签: r shiny plotly boxplot rstudio-server

我正在尝试在闪亮的应用程序中绘制一个不大的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)

1 个答案:

答案 0 :(得分:0)

看起来这个问题已经有一段时间没有受到关注了,似乎还没有解决。我可以重现上面的示例,发现如果观察值小于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      
>