[R] Trying to create R dataframe with JRI
Ralf B
ralf.bierig at gmail.com
Wed Mar 24 23:28:24 CET 2010
Hi all,
I am writing here because the JRI mailing list seems abandoned...
maybe some of you guys know an answer or has a pointer into the right
direction.
I am quite confused by the jars that exist between rServe, JRI and
rJava. What I want to do is simply using a local R instance from Java
and I thought (and still think) JRI is the way forward. I did the
following steps:
1) Installed R-2.10.0-win32.exe
2) Got rJava_0.8-3.zip (from http://www.rforge.net/rJava )
3) Start Eclipse
a) created an example project 'RTest'
b) create a folder /lib within the project directory and copied
jri.dll and JRI.jar from rJava/jri (the unzipped JRI package) into
/lib
d) copied R.dll from the /bin folder of the R installation into /lib
(now /lib contains jri.dll, JRI.jar and R.dll)
and wrote an simple test application that simply calls a command and
does not do much parameter assignment (except strings and simple
integers) -- all worked fine.
Now I want to feed data as a dataframe to R. I thought I can make
RVector objects, create RList objects from that and create REXP
dataframes from those lists. I found an example here:
http://code.google.com/p/jamsim/source/browse/trunk/JAMSIM/src/org/jamsim/r/RInterfaceHL.java?spec=svn52&r=52
...
RList rlist = new RList(vectors.size(), true);
...
// turn the rlist into a dataframe
REXP dataframe = REXP.createDataFrame(rlist);
....
both of these constructors do not exist in JRI (apparently). They must
use a different set of libraries (?) and I am now puzzeled. How can I
create a dataframe from Strings and integers? I managed to create
RVectors:
ArrayList<RVector> vectors = new ArrayList<RVector>();
for (Feature feature : freqFeatures){
RVector rVector = new RVector();
rVector.addAll(feature.getParameters().values());
vectors.add(rVector);
}
but I miss the next steps. Anybody can give some example code? (JRI
source code documentation is mostly abandoned.) What are you guys
using? Are there better alternatives for what I wanna do?
Thanks a lot,
Ralf
More information about the R-help
mailing list