我是Shiny编码新手,我正在编写代码来实现图像处理和计算。但是,由于输出文本仅在函数完成执行时才显示,所以我遇到了问题。如何渲染文本输出而不等待函数完成?
以下是代码我有一部分:
server.R
shinyServer(function(input, output) {
for(i in 1:100){
processImage(i);
output$console <- renderText({
paste(i," images completed");
})
}
processImage(i) <- function(){
# code goes here
}
}
ui.R
shinyUI(fluidPage(
titlePanel(
h4("Image Processing")
),
sidebarLayout(
sidebarPanel(
# some inputs here
),
mainPanel(
textOutput('console')
)
)
))
output$console
直到for循环结束后不会被渲染。我已经在互联网上搜索解决方案,但没有找到。谁能帮我这个?
不确定闪亮的代码,但在常规的是有一个'flush.console'功能。 –
由于'output $ console'与控制台不一样,所以flush.console不适用于我。尝试了我所知道的每一种可能的方式,但仍然无法知道如何在函数仍在运行时呈现文本。 – Woody
对您有帮助吗? http://shiny.rstudio.com/gallery/onflush-example.html –