I am using an R package that, in addition to calculating and returning things, prints some very useful info to the console. For example, it prints what iteration it is on right now.
How could I print that console output directly to my UI?
Assume this is my UI:
ui <- shinyUI(
  fluidPage(
    titlePanel("Print consol output"),
    sidebarLayout(
      sidebarPanel(actionButton("go", "Go")),
      mainPanel(
        verbatimTextOutput("console_text")
      )
    )
  )
)
My user clicks on actionButton “Go” and my package starts doing things - while sending stuff to the console at the same time. I guess, I want the content of the console to be saved as output$console_text - but I don’t know if that’s the right approach and how to do it.
I didn't want to make the code super-complicated. So, instead of a package, I created my own little printing function in Server.
server <- function(input, output, session) {
  myfunction <- function(x) { 
     for(i in 1:x) cat(i)
     return(x)
  }
  observeEvent(input$go, {
    {
       # This is probably wrong:
      output$console_text <- renderPrint(onerun <- myfunction(20))
    }
  })
}
shinyApp(ui, server)
Thank you very much!
