View source: R/withProgressShiny.R
withProgressShiny | R Documentation |
A plug-in, backward-compatible replacement for shiny::withProgress()
.
withProgressShiny(
expr,
...,
message = NULL,
detail = NULL,
inputs = list(message = NULL, detail = "message"),
env = parent.frame(),
quoted = FALSE,
handlers = c(shiny = handler_shiny, progressr::handlers(default = NULL))
)
expr , ... , env , quoted |
Arguments passed to |
message , detail |
(character string) The message and the detail message to be passed to |
inputs |
(named list) Specifies from what sources the Shiny progress
elements 'message' and 'detail' should be updated. Valid sources are
|
handlers |
Zero or more progression handlers used to report on progress. |
The value of shiny::withProgress.
This function requires the shiny package and will use the
handler_shiny()
progressr handler internally to report on updates.
library(shiny)
library(progressr)
app <- shinyApp(
ui = fluidPage(
plotOutput("plot")
),
server = function(input, output) {
output$plot <- renderPlot({
X <- 1:15
withProgressShiny(message = "Calculation in progress",
detail = "Starting ...",
value = 0, {
p <- progressor(along = X)
y <- lapply(X, FUN=function(x) {
Sys.sleep(0.25)
p(sprintf("x=%d", x))
})
})
plot(cars)
## Terminate the Shiny app
Sys.sleep(1.0)
stopApp(returnValue = invisible())
})
}
)
local({
oopts <- options(device.ask.default = FALSE)
on.exit(options(oopts))
if (interactive()) print(app)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.