Following this I have implemented a container for continuously capturing R
console output including scrolling capabilities.
The corresponding bit in ui.R
looks like so:
shiny::tabPanel(
title = "Console
shiny::verbatimTextOutput(
outputId = "consolemessages",
placeholder = TRUE),
shiny::tags$head(
shiny::tags$style(
"#consolemessages{overflow-y: scroll; max-height: 800px;}"
)
)
)
In server.R
I am using the following function to capture the R
console content:
capture_console_output <- function(
fnctn,
output_id,
output_header = NULL)
{
withCallingHandlers(
{
if (!is.null(output_header))
{
shinyjs::html(
id = output_id,
html = output_header,
add = TRUE
)
}
output <- fnctn
},
message = function(m) {
shinyjs::html(id = output_id, html = m$message, add = TRUE)
}
)
return(output)
}
I am aiming at a scroll state that automatically scrolls to the end of this container whenever something is added. How would that be achievable?