2
在我的Shiny页面上,有一个步骤用于读取大型日志文件,该文件需要25s才能加载。我想在用户点击一个按钮后显示一个进度条。否则,他们可能会认为它在等待时不工作。R Shiny放置在哪里withProgress
#ui.R
#I have an actionButton to activate reading the log file
actionButton("getLog","Get Log data")
#server.R
observeEvent(input$getLog, {
nL = as.numeric(countLines("/script/cronlog.log"))
Log = read.table("/script/cronlog.log",sep = ";",skip = nL-1000)
LogFile = tail(Log,100)
colnames(LogFile) = "cronlog"
})
我正在尝试使用withProgress,但我不知道如何使用它来包装代码。我想是这样的:
observeEvent(input$getLog, {
withProgress(message = 'Calculation in progress',
detail = 'This may take a while...', value = 0, {
for (i in 1:60) {
incProgress(1/60)
Sys.sleep(0.25)
}
})
nL = as.numeric(countLines("/script/cronlog.log"))
Log = read.table("/script/cronlog.log",sep = ";",skip = nL-1000)
LogFile = tail(Log,100)
colnames(LogFile) = "cronlog"
})
进度条没有出现,但它似乎是加载进度的进度条,这使得该方法甚至更长的时间之后运行。我想我没有正确包装代码。
有什么建议吗?
预先感谢您!