I want R to produce, for example, normal data and then use this data in Java. I know there is a function to convert an REXP object to an array but it doesn't seem to work. Here is what I have:
REXP x;
x = re.eval("rnorm(100,50,10)");
double[] test = x.asDoubleArray();
System.out.println(x);
System.out.println(test);
I have printed both out to see what is wrong. The results are as follows:
[REAL* (61.739814266023316, 40.25177570831545, 36.09450830843867, 48.06821029847672,...etc)]
[D@61de33
The problem is how R returns the results to java; it tells java what x is, if they were strings it would say [String*(..whatever..)]. I just want what is in the bracket. Also the line it returns is a string regardless.
I will be working with large data so I want it to be fast. I had tried to use subsets, extracting what is in the brackets and then parsing them to doubles but there must be a better solution. Also that doesn't seem to work for data with more than 100 points.