如果我运行此示例:incubator example
进度条看起来像这样:
但是当我在自己的电脑上运行相同的代码时:
library(shiny)
library(shinyIncubator)
server <- function(input, output, session) {
output$plot <- renderPlot({
if (input$go == 0)
return()
# Wrap the entire expensive operation with withProgress
withProgress(session, {
setProgress(message = "Calculating, please wait",
detail = "This may take a few moments...")
Sys.sleep(1)
setProgress(detail = "Still working...")
Sys.sleep(1)
anotherExpensiveOperation()
Sys.sleep(1)
setProgress(detail = "Almost there...")
Sys.sleep(1)
plot(rnorm(100), rnorm(100))
})
})
anotherExpensiveOperation <- function() {
# It's OK for withProgress calls to nest; they will have
# a stacked appearance in the UI.
#
# Use min/max and setProgress(value=x) for progress bar
withProgress(session, min = 0, max = 10, {
setProgress(message = "Here's a sub-task")
for (i in 1:10) {
setProgress(value = i)
if (i == 7)
setProgress(detail = "Sorry, this is taking a while")
Sys.sleep(0.3)
}
})
}
}
ui <- shinyUI(fluidPage(
progressInit(),
h1("Progress demo"),
sidebarLayout(
sidebarPanel(
"This is a demonstration of the progress indicator ",
"from the",
a(href="https://github.com/rstudio/shiny-incubator",
"shiny-incubator"),
"package.",
hr(),
actionButton("go", "Run")
),
mainPanel(
plotOutput("plot")
)
)
))
shinyApp(ui = ui, server = server)
进度条看起来像这样:
要安装shinyIncubator,请根据需要安装devtools包(install.packages("devtools")
)并运行:
devtools::install_github("shiny-incubator", "rstudio")
答案 0 :(得分:0)
由于版本0.10.2闪亮包含进度条。默认进度条将覆盖shinyIncubator图形。对shinyIncubator的未来更新将删除其进度条。
更多信息: Discussion