I want to show a progress bar if something in eventReactive()
is evaluated.
However, withProgress()
doesn't seem to work as expected if nothing is added directly to the output. (See the first part below that gets triggered by input$go1
.)
In a dashboard with multiple panels it shows up if one navigates to another subpage. However, I want to have it showing up immediately after hitting the button.
Can anybody help to fix this problem in the example below?
library(shiny)
ui <- fluidPage(
actionButton("go1", "Go! Number 1"),
actionButton("go2", "Go! Number 2"),
plotOutput("plot")
)
server <- function(input, output) {
eventReactive(input$go1,{
withProgress({
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.25)
}
}, message = "Doesn't show up!")
})
output$plot <- renderPlot({
input$go2
withProgress({
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.1)
}
}, message = "Shows up!")
plot(cars)
})
}
shinyApp(ui = ui, server = server)