I have coded an MCMC sampler using Rcpp
(specifically, RcppArmadillo
). I would like my sampler to print periodic status messages to the R console, but the messages appear all at once when the sampler terminates. The output statement is :
Rcout << "Progress => "
<< double(iterations) / double(maxit) * 100
<< "%"
<< std::endl;
Can this code be augmented so that its output appears on the R console immediately?
R version: 2.14.1
platform: Darwin 9.8.0
Rcpp version: 0.9.10
This behaviour has been implemented in Rcpp
0.10.0 (to be released soon) following advice from answers to this question.
In the meantime, you can manually call R_FlushConsole
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With