相关疑难解决方法(0)

是否有可能停止在闪亮的内部执行R代码(不停止闪亮的过程)?

假设我有一个闪亮的应用程序,其功能可能需要很长时间才能运行.是否有可能有一个"停止"按钮告诉R停止长时间运行的呼叫,而不必停止应用程序?

我的意思是:

analyze <- function() {
  lapply(1:5, function(x) { cat(x); Sys.sleep(1) })
}

runApp(shinyApp(
  ui = fluidPage(
    actionButton("analyze", "Analyze", class = "btn-primary"),
    actionButton("stop", "Stop")
  ),
  server = function(input, output, session) {
    observeEvent(input$analyze, {
      analyze()
    })
    observeEvent(input$stop, {
      # stop the slow analyze() function
    })
  }
))
Run Code Online (Sandbox Code Playgroud)

编辑:发光讨论的x-post

r shiny

15
推荐指数
2
解决办法
7029
查看次数

标签 统计

r ×1

shiny ×1