[Rd] How to create a table structure in Java code?

Morkus morkus at protonmail.com
Thu Oct 26 19:23:29 CEST 2017


I have one small remaining problem.

Now that I can read in the CSV data, thanks again for that help, I create a data frame from all the REXPDouble and the one REXPString object and I'm then trying to do a boxM (Box's M) test.

The documentation says that a data frame should work with boxM so maybe I'm back in "quote hell"?

I've tried the "problem command" (two lines below) both with putting the entire boxM command inside the quotes and having the "myDf" be outside the quotes.

The line of code below that still throws a parse error is:

REXP boxMResult = rConnection.parseAndEval( "boxM(" + myDf+ "[,-5], " + myDf + " [, 5])");

Thanks again to all...this is an incredible forum!!!

I offer a virtual beer to whomever helps! :)




String inputIris = "5.1,3.5,1.4,0.2,setosa\n" +
"4.9,3,1.4,0.2,setosa\n" +
"5.5,2.4,3.7,1,versicolor\n" +
"5.8,2.7,3.9,1.2,versicolor\n" +
"6,2.7,5.1,1.6,versicolor\n" +
"7.9,3.8,6.4,2,virginica\n" +
"6.4,2.8,5.6,2.2,virginica\n" +
"6.3,2.8,5.1,1.5,virginica\n" +

(some IRIS data removed above for brevity.)

List tableRead = rConnection.eval(
"read.csv(textConnection(\"" + inputIris + "\"), header = FALSE)").asList();    // Yes works!!!

double[] d1 = ((REXPVector) ((RList) tableRead).get(0)).asDoubles();
double[] d2 = ((REXPVector) ((RList) tableRead).get(1)).asDoubles();
double[] d3 = ((REXPVector) ((RList) tableRead).get(2)).asDoubles();
double[] d4 = ((REXPVector) ((RList) tableRead).get(3)).asDoubles();
int[] d5 = ((REXPFactor) ((RList) tableRead).get(4)).asIntegers() ;

// create data frame with data extracted from tableRead List object.REXP myDf = REXP.createDataFrame(new RList(
new REXP[]
new REXPDouble(d1),
new REXPDouble(d2),
new REXPDouble(d3),
new REXPDouble(d4),
new REXPInteger(d5)

>>>> ERROR HERE >>>> REXP boxMResult = rConnection.parseAndEval( "boxM(" + myDf+ "[,-5], " + myDf + " [, 5])");

eval failed, request status: R parser: syntax error
org.rosuda.REngine.REngineException: eval failed, request status: R parser: syntax error
	[[alternative HTML version deleted]]

More information about the R-devel mailing list