Rserve | powerful server providing access to R from many languages | Runtime Evironment library
kandi X-RAY | Rserve Summary
kandi X-RAY | Rserve Summary
Fast, flexible and powerful server providing access to R from many languages and systems
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Rserve
Rserve Key Features
Rserve Examples and Code Snippets
public double mean(int[] values) throws REngineException, REXPMismatchException {
RConnection c = new RConnection();
c.assign("input", values);
return c.eval("customMean(input)")
.asDouble();
}
Community Discussions
Trending Discussions on Rserve
QUESTION
If I call R code from Java within GraalVM (using GraalVM's polyglot function), does the R code and the Java code run on the same Java thread (ie there's no switching between OS or Java threads etc?) Also, is it the same "memory/heap" space? That is, in the example code below (which I took from https://www.baeldung.com/java-r-integration)
...ANSWER
Answered 2022-Feb-02 at 20:50does the R code and the Java code run on the same Java thread. Also, is it the same "memory/heap" space?
Yes and yes. You can even use GraalVM VisualVM to inspect the heap: it provides standard Java view where you can see instances of FastR internal representations like RIntVector
mingled with the rest of the other Java objects, or R view where you can see integer vectors, lists, environments, ...
does the call rBindings.getMember("c").execute(values) cause the values object (an array of ints) to be copied?
In general yes: most objects are passed to R as-is. Inside R you have two choices:
- Explicitly convert them to some concrete type, i.e.,
as.integer(arg)
, which does not make a copy, but tells R explicitly how you want that value to be treated as "native" R type including R's value semantics. - Leave it up to the default rules, which will be applied once your objects is passed to some R builtin, e.g.,
int[]
is treated as integer vector (but note that treating it as a list would be also reasonable in some cases). Again no copies here. And the object itself keeps its reference semantics.
However, sometimes FastR needs to make a copy:
- some builtin functions cannot handle foreign objects yet
- R language often implicitly copies vectors, because of its value semantics, arguments coercion, etc.
- when a vector is passed to native R extension, we need to move its data to off heap memory
I would say that if you happen to have a very large vector, say GBs of data, you need to be very careful about it even in regular R. Note: FastR vectors are by default backed by Java arrays, so their size limitations apply to FastR vectors too.
Finally, does calling a polyglot function (in this case customMean implemented in R) have the same overhead as calling a native Java function?
Mostly yes, except that the function cannot be pulled and inlined into the surrounding Java code(+). The call itself is as fast as regular Java call. For the example you give: it cannot be optimized as you suggest, because the R function cannot be inlined(+). However, I would be very skeptical that any compiler can optimize this as you suggest even if both functions where pure Java code. That being said, yes: some things that compiler can optimize, like eliminating some useless computations that it can analyze well, is not going to work because of the impossibility to inline code across the Java <-> R boundary(+).
(+) Unless you'd run the Java code with Espresso (Java on Truffle), but then you would not be using Context API but Espresso's interop support.
QUESTION
Im trying to start Rserve from my java backend using Runtime exec function. I can normally execute linux command like killall to stop the process but i was unable to start it. You can start Rserve from command line using this
...ANSWER
Answered 2021-Jun-09 at 12:55I have looked at some documentation and found something. Try this:
QUESTION
Condider that I've built my application as in te example below:
...ANSWER
Answered 2020-Jul-29 at 17:11Looking at the source code I'd suggest adding the named parameter background=TRUE
to backend$start(app, http_port = 8080)
. This parameter is FALSE by default (line 36), when TRUE Rserve will be started in a new detached R-session (line 93). (Btw, leaving out said parameter you can check that the disconnect kills your running R-session by keeping a second SSH-connection open and listing running processes with a filter: ps aux | grep bin/exec/R
before and after the disconnect)
If using said parameter works you might also want to look into server restarts. From the looks of it I'd say RestRserve cannot actually handle that by itself and you might need a small service script.
QUESTION
I'm calling Rserve from python and it runs for basic operations, but not if I call basic functions as min
...ANSWER
Answered 2020-Jul-02 at 09:40You should try min(unlist(x))
.
If the list is simple, you may just try as.data.frame(x).
For some more complicate list, StackOverFlow has many other answers.
QUESTION
I try to implement login in my spring app. In sample project it works perfect, but in work project it works partially. In my work project after login becomes available access to private pages, but next code don't perfomes correctly in html page:
...ANSWER
Answered 2020-May-27 at 21:47I've added maven dependency:
QUESTION
In short: I'm trying to run this hexbin example which works fine unless I replace plot
with graphics::plot
. The latter throws following error:
ANSWER
Answered 2020-Feb-17 at 09:52Class hexbin
is an S4 class and the package defines an S4 generic and a method for plot
. (The source code is here). There is no S4 generic for plot
in the graphics
package namespace, only an S3 generic.
The solution is therefore very simple:
QUESTION
I am trying out the very interesting package RestRserve from with RStudo server that I installed on an AWS instance.
This is de code I use:
...ANSWER
Answered 2020-Jan-26 at 08:46Likely you need two additional steps:
- make sure you allow traffic from internet to 8080 port
- make sure you use public IP (or better DNS) of your instance
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Rserve
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page