Reputation: 2042
I have only started using shiny 2 days back so forgive me if this is very naive question but I have looked around and cannot find a simple answer. I am creating an app that will take a while to complete. I want to keep the output updated with intermediate steps of the program. I can print to the output once the program completes but how do I print intermediate steps.
Eg in the following minimal app code it prints the numbers 1 to 10 after 10 seconds but how can I make it print at each second interval?
library(shiny)
runApp(list(
ui = basicPage(
h2('Multiple output'),
actionButton("goButton", "Go!"),
textOutput("out")
),
server = function(input, output) {
output$out = renderText({
if(input$goButton == 1 ) {
msg = NULL
for(i in 1:10) {
Sys.sleep(1)
msg = paste(msg,i)
}
msg
}
})
}
))
Upvotes: 1
Views: 1567
Reputation: 2042
Thanks for your help. I found this thread to best meet my request Update graph/plot with fixed interval of time
I actually ended up using invalidateLater http://www.inside-r.org/packages/cran/shiny/docs/invalidateLater
Upvotes: 1
Reputation: 16004
https://stackoverflow.com/a/20290366/239923
You may consider using alerts from the ShinySky pacakge to show an alert?
Upvotes: 1
Reputation: 10215
That's a very popular request on the shiny forum, and the margin of Stack Overflow is not wide enough to show the detailed answer (pardon, Fermat). The trick is to use javascript to check for class shiny-busy
.
var isBusy = $('html').hasClass('shiny-busy');
Joe Cheng has a sample on
https://gist.github.com/jcheng5/4495659
You may also search the shiny forum for "progress bar".
Upvotes: 1