RJava printing to R console
I have been using the rJava package to call java codes from R lately. I use linux most of the time and run R from the terminal. I didn't realize there was a huge I / O problem until I recently wrote a package using rJava. I want to know if anyone can help me with this.
The idea was to run the MCMC sampler using Java so that it is much faster. I want to print a message about the progress of each kth iteration. In Java, I am using System.out.printf (). It works fine when running R in the terminal, but it completely fails when running R GUI or Rstudio. Here's a list of the things I've tried:
- In the terminal, messages are printed as they are called.
- In mac Rstudio, messages are printed as they are called.
- On mac R GUI, messages are printed together when the entire Java call is complete.
- On Windows, both R GUI and Rstudio, the messages disappear completely instead of printing at all ...
I'm wondering if there is any easy way to work with the I / O stream in R? I know Rcpp has this nice Rprintf function that you can use to connect to the R console. Does anyone know if I can do something similar in Java? Thank.
Update: To let people know what I did in the end: I couldn't find anything to bypass printing for the console in all these cases, so for windows at least I added another GUI to my java codes , i.e. Created a pop-up with the required messages and a progress bar. Not ideal as it makes my package run with different looks on different platforms, but better than nothing ... Still glad to hear new thoughts on this.
source to share
No one has answered this question yet
Check out similar questions: