Progress: Reporting progress (object-oriented API)

Description Arguments Details See Also Examples

Description

Reports progress to the user during long-running operations.

Arguments

session

The Shiny session object, as provided by shinyServer to the server function.

min

The value that represents the starting point of the progress bar. Must be less tham max.

max

The value that represents the end of the progress bar. Must be greater than min.

message

A single-element character vector; the message to be displayed to the user, or NULL to hide the current message (if any).

detail

A single-element character vector; the detail message to be displayed to the user, or NULL to hide the current detail message (if any). The detail message will be shown with a de-emphasized appearance relative to message.

value

A numeric value at which to set the progress bar, relative to min and max. NULL hides the progress bar, if it is currently visible.

amount

Single-element numeric vector; the value at which to set the progress bar, relative to min and max. NULL hides the progress bar, if it is currently visible.

amount

For the inc() method, a numeric value to increment the progress bar.

Details

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.

Instantiating a Progress object causes a progress panel to be created, and it will be displayed the first time the set method is called. Calling close will cause the progress panel to be removed.

Methods

initialize(session, min = 0, max = 1)

Creates a new progress panel (but does not display it).

set(value = NULL, message = NULL, detail = NULL)

Updates the progress panel. When called the first time, the progress panel is displayed.

inc(amount = 0.1, message = NULL, detail = NULL)

Like set, this updates the progress panel. The difference is that inc increases the progress bar by amount, instead of setting it to a specific value.

close()

Removes the progress panel. Future calls to set and close will be ignored.

See Also

withProgress

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Only run examples in interactive R sessions
if (interactive()) {

ui <- fluidPage(
  plotOutput("plot")
)

server <- function(input, output, session) {
  output$plot <- renderPlot({
    progress <- Progress$new(session, min=1, max=15)
    on.exit(progress$close())

    progress$set(message = 'Calculation in progress',
                 detail = 'This may take a while...')

    for (i in 1:15) {
      progress$set(value = i)
      Sys.sleep(0.5)
    }
    plot(cars)
  })
}

shinyApp(ui, server)
}

ymd526442121/Rproject_shiny documentation built on May 4, 2019, 5:31 p.m.