1

I have created an shiny app which runs a function() and generates multiple outputs to render to the UI. Also, this function has been wrapped with "eventReactive()" which controlled by an "ActionButton" in the UI.

However, since this function is an optimization function which iterates 5 - 10 minutes, people have to wait till the search function finish to see the result (Multiple function outputs).

I would like my user to see the modeling progress (like print()s in the search function) while the function is running (in realtime) instead of just waiting. So, I am wondering if it is possible to use "renderPrint" or "renderText" in a way that can render the "prints" in the search function while it is running?

The basic structure of my shiny App is:

server.r

# source optimal_fun()
source("optimal_fun.r")

# server.r main
shinyServer(function(input, output) {

# ----------- use 'eventreactive()' for 'action button'
model <- eventReactive(input$goButton, {
         optimal_fun()
         })

# render fun() result1
output$result1 <- renderTable({
    model()$result1
  })

# render fun() result2
output$result1 <- renderTable({
    model()$result2
  })

# render fun() result3
output$result1 <- renderTable({
    model()$result3
  })

# ------- render all outputs to UI
output$tb <- renderUI({
             tabsetPanel(tabPanel("result1", tableOutput("result1")),
                         tabPanel("result2", tableOutput("result2")),
                         tabPanel("result3", tableOutput("result3")))
             })
})

Thanks! Any suggestion or guidance would be really appreciated.:)

Mark Li
  • 429
  • 1
  • 7
  • 21
  • You may want to look up an example of using progress bar with Shiny. There don't seem to be very good options without writing custom javaScript, but workable. – Gopala May 15 '16 at 23:42
  • The only option would be to write custom javascript to update the UI. Since both Shiny and R are single-threaded, they cannot update the UI while the optimization process is running. Here is an example that you can base on http://stackoverflow.com/questions/17325521/r-shiny-display-loading-message-while-function-is-running/22076307#22076307 – Xiongbing Jin May 16 '16 at 03:16
  • @Gopala Thank you! Progress bar is all I need here. :) – Mark Li May 16 '16 at 15:33
  • @warmoverflow Thanks for the link! I will look into it.:) – Mark Li May 16 '16 at 15:57

0 Answers0