[R] calling r from java (Eduard Drenth)

Adrian Trapletti @dr|@n @end|ng |rom tr@p|ett|@org
Mon Nov 30 18:34:35 CET 2020


Calling R via Rserve is faster than a REST based solution. However, if you
do some non-trivial computation in R, then the calling overhead is
insignificant. A REST based solution is more flexible. A REST API can be
called e.g. directly from a Javascript UI and the indirection via a Java
backend is not necessary. I see that there is a Javascript client for
Rserve https://github.com/cscheid/rserve-js but the last release is from
2013. Or if you think later that Python is more suited to do this type of
work, then you can simply replace the R REST service with a Python REST
service without touching the Java code.

Cheers,
Adrian

*Adrian Trapletti*

Steinstrasse 9b, 8610 Uster, Switzerland
P +41 44 994 56 30  |  M +41 79 103 71 31
adrian using trapletti.org  |  www.trapletti.org


On Sun, Nov 29, 2020 at 9:12 AM Eduard Drenth <edrenth using fryske-akademy.nl>
wrote:

> Because of efficiency? But almost all development I do is in
> Java/Xml/XQuery so I am interested in efficiently integrating the two. And
> for our small institution it is important to limit the number of
> technologies / frameworks.
>
> Bye, Eduard
>
> -----Original Message-----
> *From*: Adrian Trapletti <adrian using trapletti.org
> <Adrian%20Trapletti%20%3cadrian using trapletti.org%3e>>
> *To*: Eduard Drenth <edrenth using fryske-akademy.nl
> <Eduard%20Drenth%20%3cedrenth using fryske-akademy.nl%3e>>
> *Cc*: R-help using r-project.org
> *Subject*: Re: calling r from java (Eduard Drenth)
> *Date*: Sat, 28 Nov 2020 20:36:14 +0100
>
> Hi Eduard,
>
> I recommend separating the R quant code from Java and deploy the R code as
> a REST service, e.g. using https://github.com/opencpu/opencpu
>
> Best regards
> Adrian
>
> Adrian Trapletti
>
> Steinstrasse 9b, 8610 Uster, Switzerland
> P +41 44 994 56 30  |  M +41 79 103 71 31
> adrian using trapletti.org  |  www.trapletti.org
>
> On Sat, Nov 28, 2020 at 12:00 PM <r-help-request using r-project.org> wrote:
> >
> > Send R-help mailing list submissions to
> >         r-help using r-project.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> >         https://stat.ethz.ch/mailman/listinfo/r-help
> > or, via email, send a message with subject or body 'help' to
> >         r-help-request using r-project.org
> >
> > You can reach the person managing the list at
> >         r-help-owner using r-project.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of R-help digest..."
> >
> >
> > Today's Topics:
> >
> >    1. calling r from java (Eduard Drenth)
> >    2. Re: calling r from java (Bert Gunter)
> >    3. Re: calling r from java (Jeff Newmiller)
> >    4. Re: calling r from java (Bert Gunter)
> >    5. Re: calling r from java (Abby Spurdle)
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Fri, 27 Nov 2020 16:47:54 +0000
> > From: Eduard Drenth <edrenth using fryske-akademy.nl>
> > To: "r-help using r-project.org" <r-help using r-project.org>
> > Subject: [R] calling r from java
> > Message-ID:
> >         <
> fa5236c2ca174ba8e839129cb0b6b047527a0f67.camel using fryske-akademy.nl>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Dear all,
> >
> > As a java developer I prefer to develop rest services using jax-rs.
> >
> > Now I developed a service that executes Rscript (Using ProcessBuilder),
> > sends text to stdin of the process and reads from stdout of the
> > process.
> >
> > Works fine, but this is inefficient, because every call reloads all
> > that is needed.
> >
> > I have looked into this:
> >
> > https://github.com/microsoft/java-client-library
> > https://rforge.net/Rserve/
> > several other sources on stackoverflow etc.
> >
> > A lot of these sources seem old or not maintained.
> >
> > Now my question: Is there a preferred and maintained way to efficiently
> > call R from Java? Preferrably available in maven central?
> >
> > Regards, Eduard
> >
> >
> > --
> > Eduard Drenth, Software Architekt
> >
> > edrenth using fryske-akademy.nl
> >
> > Doelestrjitte 8
> > 8911 DX  Ljouwert
> > +31 58 234 30 47
> > +31 62 094 34 28 (privé)
> >
> > skype: eduarddrenth
> > https://github.com/eduarddrenth
> > frisian.eu
> > gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth
> >
> >
> > Op freed bin ik thús/wurkje ik minder
> >
> >
> >
> >
> >
> > -------------- next part --------------
> > A non-text attachment was scrubbed...
> > Name: signature.asc
> > Type: application/pgp-signature
> > Size: 488 bytes
> > Desc: This is a digitally signed message part
> > URL: <
> https://stat.ethz.ch/pipermail/r-help/attachments/20201127/7d818716/attachment-0001.sig
> >
> >
> >
>
> --
>
> Eduard Drenth, Software Architekt
>
> edrenth using fryske-akademy.nl
>
> Doelestrjitte 8
> 8911 DX  Ljouwert
> +31 58 234 30 47
> +31 62 094 34 28 (privé)
>
> skype: eduarddrenth
> https://github.com/eduarddrenth
> frisian.eu
> gpg: https://pgp.surfnet.nl/pks/lookup?search=eduarddrenth
>
>
> Op freed bin ik thús/wurkje ik minder
>
>
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list