jri

Java/R Interface (JRI)

百般思念 提交于 2019-12-22 18:56:13
问题 I want to call some R code from within Java, on a Linux machine that has R installed already, so the Java/R Interface (JRI) is needed. However, I am not sure how to go about this. The JRI homepage says that the package is bundled in rJava. So, I downloaded rJava-0.9.3.tar.gz from the rJava Files section, and unzipped it, getting (among other things) a lot of Java source files (and their corresponding classes) in the src/java folder, plus 2 JARs (JRIEngine.jar and REngine.jar) in the inst/jri

Setting up Java R Interface (JRI) on Windows

杀马特。学长 韩版系。学妹 提交于 2019-12-18 05:13:09
问题 I have followed guides on the web and looked at questions on stackoverflow but I am still not able to set up JRI on Windows. Here are the steps I have taken: 1) Install R 2) Execute install.packages("rJava") in R to install rJava 3) Create a R_HOME system variable with value C:\Program Files\R\R-3.1.2 4) Add the following to my PATH variable: C:\Program Files\R\R-3.1.2\bin\x64;C:\Users\USERNAME\Documents\R\win-library\3.1\rJava\jri\x64 5) Added the JRI.jar (located in C:\Users\USERNAME

Evaluating expressions called from Java in R. Out of Memory Error: Java Heap

狂风中的少年 提交于 2019-12-14 04:22:06
问题 I have an issue loading a large dataset into R from Java. The problem is actually with the function I am using: re.eval() . I want to load a file into R so that I can analyse/manipulate it in R, however I want to do this from Java (this is in order to build a GUI). What I want the function to do is parse and evaluate the string I provide, however, the eval function parses, evaluates and returns the result. I get an out of memory error from java regarding the heap size. This is the code I have

exporting plotted variable shows blank image

被刻印的时光 ゝ 提交于 2019-12-13 18:40:33
问题 I am doing java and R integration using JRI. Please find below script String path = "C:\\Users\\hrpatel\\Desktop\\CSVs\\DataNVOCT.csv"; rengine.eval("library(tseries)"); rengine.eval(String.format("mydata <- read.csv('%s')",path.replace('\\', '/'))); String exportFilePath= "C:\\Users\\hrpatel\\Desktop\\CSVs\\arima3.jpg"; rengine.eval("Y <- NewVisits"); rengine.eval("t <- Day.Index"); rengine.eval("summary(Y)"); rengine.eval("adf.test(Y, alternative='stationary')"); rengine.eval("adf.test(Y,

Reading R-Errors through JRI

可紊 提交于 2019-12-12 13:05:44
问题 i'm using JRI, to talk to R through Java. If i try to get the result of my R-Code as Double i get a NullPointer. Normally this is caused by an error of R. Is it possible to get the output of the R-Console into Java in order to read the error? 回答1: Ok. Here is what I did, to solve the problem. because my REngine is a singleton i was able to perform those R-Expressions, after the creation: re.eval("log<-file('"+filepath+"')"); re.eval("sink(log, append=TRUE)"); re.eval("sink(log, append=TRUE,

JRI and ARIMA integration

独自空忆成欢 提交于 2019-12-11 15:38:10
问题 I have one last question, but I really need help on this one. The very last thing for my project is that I have to make ARIMA, to work under JRI. All everything is working, but one little piece of code is not working properly. Here's the code: re.eval("library(forecast);"); re.assign("y", arrayStr); re.eval("datats<-y;"); re.eval("arima<-auto.arima(datats);"); re.eval("fcast<-forecast(arima);"); REXP fs = re.eval("summary(fcast);"); double[] forecast = fs.asDoubleArray(); for(int i=0; i

Get same output as R console in Java using JRI

血红的双手。 提交于 2019-12-11 12:14:33
问题 When I enter the following commands directly into the R console library("xts") mySeries <- xts(c(1.0, 2.0, 3.0, 5.0, 6.0), order.by=c(ISOdatetime(2001, 1, 1, 0, 0, 0), ISOdatetime(2001, 1, 2, 0, 0, 0), ISOdatetime(2001, 1, 3, 0, 0, 0), ISOdatetime(2001, 1, 4, 0, 0, 0), ISOdatetime(2001, 1, 5, 0, 0, 0))) resultingSeries <- to.monthly(mySeries) resultingSeries I will get an output like this mySeries.Open mySeries.High mySeries.Low mySeries.Close Jan 2001 1 6 1 6 When I look into the attributes,

Problems with JRI

与世无争的帅哥 提交于 2019-12-11 08:15:17
问题 I am trying to run an example of JRI and being unsuccessful, here is a link to the example. http://blog.comsysto.com/2013/07/10/java-r-integration-with-jri-for-on-demand-predictions/ import org.rosuda.JRI.Rengine; import org.rosuda.JRI.REXP; public class HelloRWorld { Rengine rengine; // initialized in constructor or autowired public void helloRWorld() { rengine.eval(String.format("greeting <- '%s'", "Hello R World")); REXP result = rengine.eval("greeting"); System.out.println("Greeting from

How I can load add-on R libraries into JRI and execute from Java?

此生再无相见时 提交于 2019-12-11 07:25:40
问题 I am working with a Java and I need to use an add-on R library and use the functions within that library. I tried the answers provided in the following questions How I can load a R script into JRI and execute from Java? Problem loading R own created libraries in Java/JRI code but I still get a NullPointerException. Can anyone point out the error. Thankyou Here is the code which I am using: import org.rosuda.JRI.REXP; import org.rosuda.JRI.RVector; import org.rosuda.JRI.Rengine; public class

Problem loading R own created libraries in Java/JRI code

醉酒当歌 提交于 2019-12-10 10:52:51
问题 I created my own new R library (called "Media"). There is no problem when I try to load it with RGui, and I can call the functions defined in the new package. This is how I load it: > library(Media) But, I'm also trying to call that functions from Java/JRI code, and when I load the new R package, Java doesn't seem to find the pacakge, throwing the message "Error in library(Media) : object 'Media' not found" This is my current code using JRI: REXP rexpSetFolder = re.eval("setwd('C:/Users