首页 > 解决方案 > 如何在spotfire中显示r代码的进度

问题描述

有没有人找到一种方法来显示spotfire中r代码的进度。例如,它是如何进入 for 循环的。所以代码在spotfire之外的r中看起来像这样:

total <- 20
# create progress bar
pb <- txtProgressBar(min = 0, max = total, style = 3)
for(i in 1:total){
   Sys.sleep(0.1)
   # update progress bar
   setTxtProgressBar(pb, i)
   i
}

我很难想出一个解决方案,因为在程序完成之前,spotfire 不会输出文本。上面的例子没有产生任何可以观察到的东西。任何关于如何在 r 代码在 spotfire 中运行或创建进度条时查看输出文本的想法都会很棒。谢谢你。

标签: rspotfire

解决方案


I cannot see a way to show the progress bar real time. But if you want to get an idea of the timing of your code execution (after it's finished) you could put some old-fashioned print statement in your loop, such as print(paste(i,Sys.time())) and enable data function debugging through Tools>Options>Data functions>Enable data function debugging. Once your data function has finished running, you can see what's been printed from the Notification panel: a yellow warning dot appears to show that there is data function debug output. I am not sure in which version of Spotfire this options was introduced. P.S. in your original code the progress bar can be printed by substituting print(i) to i, but it does not really render properly within TERR/Spotfire, the segment is always of the same length. I have not tried playing with progress bar options.


推荐阅读