-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples of R embedded in Java-Processing #71
Comments
Yes, I had the idea to make java and R work together. I am not sure in what form it may take, but it is really interesting 😄 We should do some design research about how they integrate before we implement the interesting pattern. |
If we could hide renjin from the code, it will be awesome: void setup() {
double x = 19;
$begin
y <- rpois(100,lambda=3)
$end
for (int i = 0; i < y.size(); i++) {
point(x, y[i])
}
} We could define some tags such as But to be fair, it seems impossible to implement. |
Not impossible to implement -- Jupyter notebooks, Beaker, and other notebook-paradigm multi-language systems implement mixing of R into scripting languages like Python or Javascript use an approach that is something like your example above, using "magic commands". However, I think this would be way, way too much to take on for GSOC. A more reasonable thing would be to create an example that simply re-implements the basic mjkallen example, only pointing to the Processing.R mode's local jar (which is the same "jar-with-dependencies" as the example). Once that worked, we might choose to develop more examples in the future, or not. For a future post-GSOC project, another way of embedding R into Java using the Python.R mode might be something like the equivalent of the way that PShaders work in Processing. https://processing.org/tutorials/pshader/ I haven't checked yet, but this may already exist in Renjin -- an Object that wraps a Renjin ScriptEngine up with a particular piece of code, either imported as a string or loaded from an external .R file. |
Jupyter doesn't allow the interaction between Java and R, IMO. For example, using variable in Java as a parameter in a function in R code. And mjkallen's example is more like Java code, not R code. If we support Java in Processing.R, it is a little weird, IMO. The post-GSoC idea seems cool and feasible, I will have a look on pshader. |
That's right, I was giving Jupyter magicks as an example of mixing R and Python, not R and Java. I believe that Beaker notebooks allow mixing R and Java. Still, those are huge projects. I'm not suggesting that Processing.R should change. I'm pointing out that installing Processing.R installs renjin. Processing.R could come with a bunch of R mode examples AND a single Java mode "embedded R" example. While in Java mode, that Embedded R example would show how to call the locally installed renjin as per mjkallen's sketch. |
That is a good idea 🤔 |
I created a test Processing(Java) sketch that implements this idea, based on a Java example by mjkallen. It works, but it requires that the sketch
It would be nice if the sketch could simply import the part of renjin that it needs directly from the Processing.R mode! Then installing Processing.R would also simultaneously enable basic R-in-Java mode. However, I think that the
|
This came up in a discussion on the Renjin listserv: an example of using renjin inside a Processing(Java) sketch, rather than the other way around (using Renjin to power a Processing mode).
It isn't directly relevant to Processing.R as a mode -- but someday it might actually be interesting to include an example of that in the Processing.R example set. Install the R mode in PDE, switch to a Java sketch, then import renjin from the R mode. Not the core goal of this project, but potentially of interest -- and it expands the options for community engagement!
The text was updated successfully, but these errors were encountered: