Rcpp: Mac shows loading wheel and almost freeze

十年热恋 提交于 2019-12-06 12:09:44

The question is about R.app on the Mac, not Rgui on Windows. The solution below works for me: follow Rprintf with R_FlushConsole and R_ProcessEvents, like this:

RNGScope scope;
for (int i = 0; i < 100; i++) {
    sleep(1); // sleep one second at each iteration. this sleep is
              // replaced by something in my code
if (i%20==0) {
  Rprintf("\v%d iterations are done...\n",i);
  R_FlushConsole();
  R_ProcessEvents();
}

return wrap(1);

Rgui buffers the output. I don't use Rgui, but try and find setting which controls whether or not output is buffered or not. For R code you could use flush.console to force the output to be shown, but I'm not entirely sure how this would work with C++ code.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!