Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using R programming in java

Tags:

We are working on a complex statistical project on Java. We did the original code in the R programming language. Is there a way to convert this code to Java code (converter) or otherwise how can we use R in a Java project?

like image 600
Prashant Avatar asked Oct 27 '10 15:10

Prashant


People also ask

Can we use R in Java?

R is one of the most commonly used software packages for statistical computing and graphics and Java is the most commonly used programming language. rJava is a JNI (Java Native Interface)-based, R-to-Java interface with which Java objects may be created and Java methods called and Java fields accessed from R.

How do I run an R in Java?

Using it from Java is as simple as: Context context = Context. newBuilder("R"). allowAllAccess(true).

What is use of R in Java?

'\r' is the representation of the special character CR (carriage return), it moves the cursor to the beginning of the line. '\n'(line feed) moves the cursor to the next line . On windows both are combined as \r\n to indicate an end of line (ie, move the cursor to the beginning of the next line).

What is R package in Java?

R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation.


1 Answers

While I'm unaware of a 'converter', there is an interface called rJava which will allow you to run R code directly from Java.

http://www.rforge.net/rJava/

rJava is a simple R-to-Java interface. It is comparable to the .C/.Call C interface. rJava provides a low-level bridge between R and Java (via JNI). It allows to create objects, call methods and access fields of Java objects from R.

In a sense the inverse of rJava is JRI (Java/R Interface) which provides the opposite direction - calling R from Java. JRI is now shipped as a part of the rJava package, although it still can be used as a separate entity (especially for development). Currently rJava is used as a part of JGR, iPlots and JavaGD software/packages.

like image 163
Seidr Avatar answered Oct 09 '22 07:10

Seidr