title: R Shiny - How to output text from a loop inside a reactive function that itself returns a graph
body: <p>I'm trying to create a Shiny version of a program. </p>
  
  <p>Currently, when an <code>actionButton</code> is pressed the program does some processing inside a loop, then outputs a graph. That works fine.</p>
  
  <p>What I'd like to do is have the processing loop create a block of HTML output that will change each iteration. Once complete the graph should be displayed.</p>
  
  <p>I've created simple skeleton code below to demonstrate what I'm trying to do. It fails to display any text, producing an error message saying: </p>
  
  <blockquote>
    <p>Error in func() : object 'h' not found</p>
  </blockquote>
  
  <p>Could someone please point me in the right direction? </p>
  
  <p>Thank you.</p>
  
  <pre><code>app &lt;- shinyApp(
    ui = fluidPage(
      fluidRow(  actionButton("go", "Go!") ),
  
      fluidRow(htmlOutput("html")),
  
      fluidRow(plotOutput('plot'))
   ),
  
  server = function(input, output) {
  
    myPlot &lt;- eventReactive(input$go, {
  
      for (i in 1:5){
        h &lt;- HTML("some text to be displayed")
  
        cat(i) # outputs to the console, just for debugging
  
        Sys.sleep(1) # pause for 1 second
      }
  
      hist(runif(15))
    })
  
    output$html &lt;- renderUI({ h }) # This doesn't produce any output
  
    output$plot &lt;- renderPlot({ myPlot() }) # This displays a graph after the loop terminates
  })
  
  
  runApp(app)
  </code></pre>