makejava: A wrapper function for converting R objects to Java style...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

This function converts R objects to Java arrays. If R object is numeric than the Java object is double[]. Otherwise the Java object will be String[].

Usage

1
makejava(obj, name = "")

Arguments

obj

R object that to be converted to Java style variables.

name

New variable name for created Java style variable. If R object is only a vector, a name have to be given. If R object is a list, name is inoperative.

Details

This function returns interpretable code for most frequently used dynamic Java interpreters such as Bean Shell. So this function can be used for using R codes in Java without JNI. This is an inefficient way to use R in Java but implementation is quite easy and platform independent.

Value

Returns interpretable code for Bean Shell and Java of R objects.

Note

This function generates interpretable code for Java. For other languages you can use makexml to convert R objects to XML code. XML is readable for all of the programming languages.

Author(s)

Mehmet Hakan Satman

References

See an Java implementation using this functionality in http://www.mhsatman.com/rcaller.php

See Also

makexml

Examples

1
2
3
4
5
6
7
8
#Shows the linear regression results as Java style variables
y<-rnorm(10)
x<-1:10
ols<-lm(y~x)
cat(makejava(ols))

#Shows only the residuals as double[] Residuals=new double[]{.....};
cat(makejava(ols$residuals, "Residuals"))

Runiversal documentation built on May 2, 2019, 8:23 a.m.