This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
withConsoleRedirect <- function(containerId, expr) { | |
# Change type="output" to type="message" to catch stderr | |
# (messages, warnings, and errors) instead of stdout. | |
txt <- capture.output(results <- expr, type = "output") | |
if (length(txt) > 0) { | |
insertUI(paste0("#", containerId), where = "beforeEnd", | |
ui = paste0(txt, "\n", collapse = "") | |
) |