Dear list,

There's one feature that I miss after porting a for loop from R to C++
: the possibility to add a progress bar. I used to write,

library(plyr)
l_ply(seq(1,10), function(ii) Sys.sleep(0.2), .progress = "text")

My naive attempt in C++ was unsuccessful,

using namespace std;

  cout << "["; //start progress bar
  for(ll=0; ll<N; ll++){ // loop over some variable
    if ( !( ((ll+1)*100/N) % 5) ) //  display a character every 5 steps
      cout << "=";
  }
  cout << "["; //stop progress bar

For some reason (compiler?) nothing is displayed until the end of the
execution, where the full text is suddenly displayed at once. Is there
a workaround?

Best regards,

baptiste
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to