Render interactive output outside of app.R


#1

Hello RStudio community I have been using R for a little over a year now and I began trying my hand at Rshiny for the past few months, so please be kind to me. Anyways, I am having an issue with Rshiny not displaying reactive output from a helper function outside of App.R and was hoping someone here could help me.

My issue is that the app that I am writing takes a while to run (over an hour of processing) and I’d like to have some way of displaying the status of the job to the user while the code is processing the data. But for some reason Rshiny only displays output after the entire process finishes (over an hour later). Here is a psuedo code example of what I’m doing.

library(shiny)
include("someotherscript.R", local = TRUE)
ui <- fluidPage(tableOutput(outputId = "tab"))
server <- function(input,output,session)
{
  #some other code here
  dostuff(output....)

}

shinyApp(ui=ui, server=server)

#####someotherscript.R

dostuff <- function(output...)
{
  someTable <- #append row of data to a table
  #some code here
  for(i in reallylargenumber)
  {
    someTable <- manipulatingTable(someTable)

    #a lot of code for processing
    output$tab <- renderTable(someTable)
    #this for loop will run for a few hours I need Rshiny to renderTable
    #everytime this is called so that the user can track the progress
  }
}

For some reason the renderTable function only renders the table after R returns from the dostuff() helper function back to the server function in app.R but that may takes hours before that happens and I’d like to let the user know what is going on while the script is running. Can someone please advise me on how to remedy this issue.


#2

OK for some reason I’m not getting any responses here so let me ask this another way. Is it possible to render something in shiny in a helper function that is called from the server function immediately without returning to the server?