0
我正在尝试使用进度条(通过'withProgress'命令)来监视我正在运行的管道的完成情况。闪亮的进度条过早出现
有6个进度条。通过上传文件并随后单击“actionButton”(inputId = action)来启动流水线。但是,在我上传文件之前,有3个进度条暂时出现。然后当我运行它们出现在错误的顺序管道即一个应该是第一排第二等
谁能告诉我,为什么这可能发生,我该如何纠正呢? 下面是一个什么样的管道看起来像一个示例:
#ui.R
shinyUI(fluidPage(
titlePanel("Uploading Files"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')),
tags$hr(),
checkboxInput('header', 'Header', TRUE),
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
','),
radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')
),
mainPanel(
plotOutput('plot')
)
)
))
#server.R
server <- function(input, output, session) {
read <- reactive({
dataInput <- eventReactive(input$action{
inFile <- input$file1
if (is.null(inFile))
return(NULL)
isolate(file<-read.csv(inFile$datapath, header = input$header,
sep = input$sep))
file
})
file_data_manipulated<-reactive({
withProgress(message = 'Please Wait',
detail = 'This may take a while...', value = 0, {
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.25)
}
as.numeric(dataInput())
})
})
output$plot<-renderPlot({
withProgress(message = 'Please Wait',
detail = 'This may take a while...', value = 0, {
for (i in 1:15) {
incProgress(1/15)
Sys.sleep(0.25)
}
plot(file_data_manipulated(), main = "Sample clustering to detect outliers", sub="", xlab="", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2)
abline(h = input$cutoff_filter, col = "red")
#legend("bottomleft", scc$csize>1, pt.bg=unique(node_colors), pch=21)
})
})