I would like to try using an R script behind the scenes in a XOJO desktop application. I understand that there is no practical way to make an R-based executable. But, I have read that an R script can be run from the command line.
If that is the case, then at least one question is about how to exchange information between the two. I know that I can write things to a text file that the R script then reads. But, then, there are questions about how the GUI might know about errors or when the R script is finished (can you tell that from the command line?). If the GUI needs to manage plotting (scrolling, zooming, selections of displayed data, etc), I guess that the GUI needs to read that data from a script output file rather than somehow use shared memory.
So, does anyone have suggestions, tricks, etc, about how to work in such an environment? Are there ways to minimize the install footprint? At this point, my R skills are pretty minimal so lets not dig into the darkest corners, quite yet!
Oregon Research Electronics
I wrote a statistical app that wraps R. Basically the xojo app calls R via a shell and retrieves the result, so you have access to every R function under the sun (provided you loaded the required libraries). Everything is self-contained with a copy of R v3.6.1 inside the app bundle so you don’t have to install anything outside of your app bundle.
Plotting is done using Chart Director via MBS, an excellent graphing library, not via R.
The footprint is large (475MB) because the app bundle contains all the R libs, most of which I don’t need, but I did not bother stripping out the extraneous stuff.
If this is for non-commercial use, I’m happy to send you my project and all ancillary files so you can see how I did this.
Thanks, Peter -
In an ideal world, this would end up commercial in the sense that it would be support software for instruments I make. It would not be sold separately since it would be tuned to the data formats that my instruments provide.
At this point, I am making the very first effort at learning R, so my knowledge does not even rank as “primitive”, yet. And, because of that, I don’t even know if what I want is practical. But I think that between what you write and what I saw in a recent demo, that I can see what you did. It sounds like R was running in an interactive mode and that the wrapper was supplying instruction by instruction as if a user were typing in the console. What I can’t yet see is how the results were accessed by the wrapper but I think that will become more clear as I get into it.
And thanks for the pointer toward Chart Director. In past efforts, I have spent a huge amount of time recreating charting windows. I’m not yet an MBS user though I have been in this camp since RB 0.9. Maybe it is time to bit the proverbial bullet.
So, I really appreciate your description. I’ll leave it up to you to decide whether my use falls within your idea of “commercial” or not. If it does not, I would be delighted to have a look at your project.
Oregon Research Electronics
Good enough for me Jim, pls email me off-line (email@example.com) and I’ll send you a DB link with a zip (550MB) of the whole project. You will need a license for MBS and Chart Director for a standalone build (I believe both will run unlicensed under the debugger) which I would highly recommend if you want nice graphs and don’t want to spend 3 months reinventing the wheel. This however is peripheral to the main mechanism of how I coaxed xojo and R to talk to each other which you can glean from my code.