7
希望有人能幫助我。定期捕捉cat輸出的R閃亮輸出(renderPrint)
比方說,有一個函數「例子」,這是類似於
##function from a package
example<-function(f){
#does something
cat("step 1 done....")
# etc etc
cat("step 2 done....")
return(some_data_frame)
}
##server ui code
example2<-reactive({
if(input$some_action_button==0)
return()
result<-isolate(example(input$f1))
return(result)
})
output$f2<-renderPrint({
example2()
})
是否有某種方式來捕獲功能的「貓」輸出到renderPrint,定期?假設這是一個很長的函數來處理,並且用戶獲得一些feedbabk會很好。 invalidateLater對於已經在函數中的東西不起作用(至少在我這裏試過時似乎是這樣的)。
此外,作爲次要問題,以上述方式編寫代碼會導致renderPrint同時捕獲「cat」和data.frame,可能是因爲「返回」。
如果有人能指出我正確的方向,這將是最有幫助的!謝謝!
不錯;但用'shinyjs :: html'替換'shinyjs :: text',並用html = m $ message替換text參數 –