Description Usage Arguments Details See Also Examples
Reports progress to the user during long-running operations.
1 2 3 4 5 6 7 8 9 10 | withProgress(
session,
expr,
min = 0,
max = 1,
env = parent.frame(),
quoted = FALSE
)
setProgress(message = NULL, detail = NULL, value = NULL)
|
session |
The Shiny session object, as provided by
|
expr |
The work to be done. This expression should contain calls
to |
min |
The value that represents the starting point of the
progress bar. Must be less than |
max |
The value that represents the end of the progress bar.
Must be greater than |
env |
The environment in which |
quoted |
Whether |
message |
A single-element character vector; the message to be
displayed to the user, or |
detail |
A single-element character vector; the detail message
to be displayed to the user, or |
value |
Single-element numeric vector; the value at which to set
the progress bar, relative to |
This package exposes two distinct programming APIs for working with
progress. withProgress
and setProgress
together provide
a simple function-based interface, while the Progress
reference class provides an object-oriented API.
Use withProgress
to wrap the scope of your work; doing so will
cause a new progress panel to be created, and it will be displayed the
first time setProgress
is called. When withProgress
exits,
the corresponding progress panel will be removed.
Generally, withProgress
/setProgress
should be
sufficient; the exception is if the work to be done is asynchronous
(this is not common) or otherwise cannot be encapsulated by a single
scope. In that case, you can use the Progress
reference class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
# server.R
shinyServer(function(input, output, session) {
output$plot <- renderPlot({
withProgress(session, min=1, max=15, {
setProgress(message = 'Calculation in progress',
detail = 'This may take a while...')
for (i in 1:15) {
setProgress(value = i)
Sys.sleep(0.5)
}
})
plot(cars)
})
})
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.