【发布时间】:2016-03-17 13:23:52
【问题描述】:
我一直在尝试实现一个简单的界面来在 Shiny 上运行 R 脚本。我希望我的启动应用程序能够了解它正在对用户做什么,我能想象的更简单的事情是向用户宣布一些长时间的计算将在它实际执行之前开始,到目前为止我找不到方法强制服务器在计算开始之前将更新发送到 UI,并且 UI 被阻塞直到脚本结束。谁能看到一个简单的方法来纠正这个问题,还是我已经完全改变了我解决问题的方式?
感谢您的帮助
服务器.R
shinyServer(function(input, output, session) {
Exec = reactiveValues(stateTxt = "Not started", state = 0)
output$execStatus = renderText(Exec$stateTxt)
runCalc = function() {
setwd(root)
Exec$stateTxt = "Calculating..."
source("calc.R")
Exec$stateTxt = "Finished"
}
observeEvent(input$runCalc, {runCalc()})
)
ui.R
shinyUI(pageWithSidebar(
# Application title
headerPanel("Long Calculation"),
sidebarPanel(
actionButton("runCalc", "Run Calculation")
),
mainPanel(verbatimTextOutput("execStatus"))
))
【问题讨论】:
标签: r reactive-programming shiny-server shiny