我是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 –