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.

+3
java io r printing rjava


source to share


No one has answered this question yet

Check out similar questions:

2643
Why is printing "B" significantly slower than printing "#"?
1823
What's the easiest way to print a Java array?
1205
How do I print to stderr in Python?
1087
How do I clear the output of a print function?
935
Eclipse Cannot Start - Java was started but exit code returned = 13
655
Where is Java located on Mac OS X?
452
Does anyone have benchmarks (code and results) comparing the performance of Android apps written in Xamarin C # and Java?
115
Error loading rJava in RStudio / R after "upgrade" to OSX Yosemite
eleven
Where to start with rJava?
1
Can't load rJava using Rscript on Ubuntu 18.04



All Articles
Loading...
X
Show
Funny
Dev
Pics