r - 如何在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 中运行或创建进度条时查看输出文本的想法都会很棒。谢谢你。
解决方案
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.
推荐阅读
- c# - 子对象属性更改触发父母 DependencyPropertyChanged 回调?
- jquery - 当孩子是班级时,如何访问 $(this) 选择器的孩子?
- typescript - 计算机死机后出现与 Jasmine 相关的随机错误
- python - 在保存之前确定 jpeg 和 png 图像的图像大小
- javascript - 通过扩展将 db 搜索的结果写入动态(可能是有角度的)页面
- javascript - 在 JQuery 中克隆/取消克隆
- r - 修复 ggplot() 中分类 x 轴和连续 y 轴之间的差异
- c++ - 损坏的 FBX 二进制文件
- mysql - 无法使用 pymysql 将数据插入数据库,我的语法有什么问题?
- python - Python 3 中的条件查找