1

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
      }
    })
  }
))

3 Answers 3

1

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".

Sign up to request clarification or add additional context in comments.

Comments

1

https://stackoverflow.com/a/20290366/239923

You may consider using alerts from the ShinySky pacakge to show an alert?

1 Comment

I do not want to show an alert. More like log entries from the process.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.