Cannot Compute Box's M (Three Days Trying...)
On 28/10/2017 6:26 AM, Morkus wrote:
I'm not sure what you mean. Could you please be more specific?
You were trying to eval an expression that you constructed in Java. I was suggesting that before you eval it, you print it.
If I print the string, I get: *boxM(boxMVariable[, -5], boxMVariable[, 5])*
Right, that's what I was suggesting you do. Now you've fixed the syntax error, that looks okay. If I'm reading these messages in the right order, your latest error is Error in `[.data.frame`(boxMVariable, , -5) : undefined columns selected The expression there is a funny way of printing boxMVariable[,-5]. So now you need to figure out why it thinks you've selected undefined columns. This is a little perplexing, because you're asking for all columns except column 5, and that works whether or not you have a column 5. So I'd guess there's something weird about boxMVariable. You should ask R to print it, and to print str(boxMVariable), to make sure it's a regular dataframe containing 4 numeric columns and one factor or character column. Duncan Murdoch
From this code:
.
.
.
/// assign the data to a variable.
/rConnection.assign("boxMVariable", myDf);
/// create a string command with that variable name.
/String boxVariable = "boxM(boxMVariable[, -5], boxMVariable[, 5])";
*System*./out/.*println*(*boxVariable*);? // print the string? Not sure
what is meant.
Sorry if I didn't understand your suggestion.
Look forward to hearing back from you.
Thanks,
Sent from ProtonMail <https://protonmail.com>, Swiss-based encrypted email.
-------- Original Message --------
Subject: Re: [Rd] Cannot Compute Box's M (Three Days Trying...)
Local Time: October 27, 2017 6:09 PM
UTC Time: October 27, 2017 10:09 PM
From: murdoch.duncan at gmail.com
To: Morkus <morkus at protonmail.com>, r-devel at r-project.org
<r-devel at r-project.org>
Just print the string you are asking to R to evaluate. It doesn't make
any sense as an R expression. Fix that, and things will work.
Duncan Murdoch
On 27/10/2017 3:41 PM, Morkus via R-devel wrote:
It can't be this hard, right? I really need a shove in the right
direction here. Been spinning wheels for three days. Cannot get
past the errors.
I'm doing something wrong, obviously, since I can easily compute
the Box's M right there in RStudio
But I don't see what is wrong below with the coding equivalent.
The entire code snippet is below. The code fails below on the call
to the boxM statistic call.
PLEASE HELP!!!
Thanks in advance,
------------------------------------------------------------------------
rConnection.eval("library('biotools')");
String inputIris = "5.1,3.5,1.4,0.2,setosa\n" +
"4.9,3,1.4,0.2,setosa\n" +
"4.7,3.2,1.3,0.2,setosa\n" +
"4.6,3.1,1.5,0.2,setosa\n" +
"5,3.6,1.4,0.2,setosa\n" +
"5.4,3.9,1.7,0.4,setosa\n" +
"4.6,3.4,1.4,0.3,setosa\n" +
"5,3.4,1.5,0.2,setosa\n" +
"4.4,2.9,1.4,0.2,setosa\n" +
"4.9,3.1,1.5,0.1,setosa\n" +
"5.4,3.7,1.5,0.2,setosa\n" +
"4.8,3.4,1.6,0.2,setosa\n" +
"4.8,3,1.4,0.1,setosa\n" +
"4.3,3,1.1,0.1,setosa\n" +
"5.8,4,1.2,0.2,setosa\n" +
"5.7,4.4,1.5,0.4,setosa\n" +
"5.4,3.9,1.3,0.4,setosa\n" +
"5.1,3.5,1.4,0.3,setosa\n" +
"5.7,3.8,1.7,0.3,setosa\n" +
"5.1,3.8,1.5,0.3,setosa\n" +
"5.4,3.4,1.7,0.2,setosa\n" +
"5.1,3.7,1.5,0.4,setosa\n" +
"4.6,3.6,1,0.2,setosa\n" +
"5.1,3.3,1.7,0.5,setosa\n" +
"4.8,3.4,1.9,0.2,setosa\n" +
"5,3,1.6,0.2,setosa\n" +
"5,3.4,1.6,0.4,setosa\n" +
"5.2,3.5,1.5,0.2,setosa\n" +
"5.2,3.4,1.4,0.2,setosa\n" +
"4.7,3.2,1.6,0.2,setosa\n" +
"4.8,3.1,1.6,0.2,setosa\n" +
"5.4,3.4,1.5,0.4,setosa\n" +
"5.2,4.1,1.5,0.1,setosa\n" +
"5.5,4.2,1.4,0.2,setosa\n" +
"4.9,3.1,1.5,0.2,setosa\n" +
"5,3.2,1.2,0.2,setosa\n" +
"5.5,3.5,1.3,0.2,setosa\n" +
"4.9,3.6,1.4,0.1,setosa\n" +
"4.4,3,1.3,0.2,setosa\n" +
"5.1,3.4,1.5,0.2,setosa\n" +
"5,3.5,1.3,0.3,setosa\n" +
"4.5,2.3,1.3,0.3,setosa\n" +
"4.4,3.2,1.3,0.2,setosa\n" +
"5,3.5,1.6,0.6,setosa\n" +
"5.1,3.8,1.9,0.4,setosa\n" +
"4.8,3,1.4,0.3,setosa\n" +
"5.1,3.8,1.6,0.2,setosa\n" +
"4.6,3.2,1.4,0.2,setosa\n" +
"5.3,3.7,1.5,0.2,setosa\n" +
"5,3.3,1.4,0.2,setosa\n" +
"7,3.2,4.7,1.4,versicolor\n" +
"6.4,3.2,4.5,1.5,versicolor\n" +
"6.9,3.1,4.9,1.5,versicolor\n" +
"5.5,2.3,4,1.3,versicolor\n" +
"6.5,2.8,4.6,1.5,versicolor\n" +
"5.7,2.8,4.5,1.3,versicolor\n" +
"6.3,3.3,4.7,1.6,versicolor\n" +
"4.9,2.4,3.3,1,versicolor\n" +
"6.6,2.9,4.6,1.3,versicolor\n" +
"5.2,2.7,3.9,1.4,versicolor\n" +
"5,2,3.5,1,versicolor\n" +
"5.9,3,4.2,1.5,versicolor\n" +
"6,2.2,4,1,versicolor\n" +
"6.1,2.9,4.7,1.4,versicolor\n" +
"5.6,2.9,3.6,1.3,versicolor\n" +
"6.7,3.1,4.4,1.4,versicolor\n" +
"5.6,3,4.5,1.5,versicolor\n" +
"5.8,2.7,4.1,1,versicolor\n" +
"6.2,2.2,4.5,1.5,versicolor\n" +
"5.6,2.5,3.9,1.1,versicolor\n" +
"5.9,3.2,4.8,1.8,versicolor\n" +
"6.1,2.8,4,1.3,versicolor\n" +
"6.3,2.5,4.9,1.5,versicolor\n" +
"6.1,2.8,4.7,1.2,versicolor\n" +
"6.4,2.9,4.3,1.3,versicolor\n" +
"6.6,3,4.4,1.4,versicolor\n" +
"6.8,2.8,4.8,1.4,versicolor\n" +
"6.7,3,5,1.7,versicolor\n" +
"6,2.9,4.5,1.5,versicolor\n" +
"5.7,2.6,3.5,1,versicolor\n" +
"5.5,2.4,3.8,1.1,versicolor\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" +
"5.4,3,4.5,1.5,versicolor\n" +
"6,3.4,4.5,1.6,versicolor\n" +
"6.7,3.1,4.7,1.5,versicolor\n" +
"6.3,2.3,4.4,1.3,versicolor\n" +
"5.6,3,4.1,1.3,versicolor\n" +
"5.5,2.5,4,1.3,versicolor\n" +
"5.5,2.6,4.4,1.2,versicolor\n" +
"6.1,3,4.6,1.4,versicolor\n" +
"5.8,2.6,4,1.2,versicolor\n" +
"5,2.3,3.3,1,versicolor\n" +
"5.6,2.7,4.2,1.3,versicolor\n" +
"5.7,3,4.2,1.2,versicolor\n" +
"5.7,2.9,4.2,1.3,versicolor\n" +
"6.2,2.9,4.3,1.3,versicolor\n" +
"5.1,2.5,3,1.1,versicolor\n" +
"5.7,2.8,4.1,1.3,versicolor\n" +
"6.3,3.3,6,2.5,virginica\n" +
"5.8,2.7,5.1,1.9,virginica\n" +
"7.1,3,5.9,2.1,virginica\n" +
"6.3,2.9,5.6,1.8,virginica\n" +
"6.5,3,5.8,2.2,virginica\n" +
"7.6,3,6.6,2.1,virginica\n" +
"4.9,2.5,4.5,1.7,virginica\n" +
"7.3,2.9,6.3,1.8,virginica\n" +
"6.7,2.5,5.8,1.8,virginica\n" +
"7.2,3.6,6.1,2.5,virginica\n" +
"6.5,3.2,5.1,2,virginica\n" +
"6.4,2.7,5.3,1.9,virginica\n" +
"6.8,3,5.5,2.1,virginica\n" +
"5.7,2.5,5,2,virginica\n" +
"5.8,2.8,5.1,2.4,virginica\n" +
"6.4,3.2,5.3,2.3,virginica\n" +
"6.5,3,5.5,1.8,virginica\n" +
"7.7,3.8,6.7,2.2,virginica\n" +
"7.7,2.6,6.9,2.3,virginica\n" +
"6,2.2,5,1.5,virginica\n" +
"6.9,3.2,5.7,2.3,virginica\n" +
"5.6,2.8,4.9,2,virginica\n" +
"7.7,2.8,6.7,2,virginica\n" +
"6.3,2.7,4.9,1.8,virginica\n" +
"6.7,3.3,5.7,2.1,virginica\n" +
"7.2,3.2,6,1.8,virginica\n" +
"6.2,2.8,4.8,1.8,virginica\n" +
"6.1,3,4.9,1.8,virginica\n" +
"6.4,2.8,5.6,2.1,virginica\n" +
"7.2,3,5.8,1.6,virginica\n" +
"7.4,2.8,6.1,1.9,virginica\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" +
"6.1,2.6,5.6,1.4,virginica\n" +
"7.7,3,6.1,2.3,virginica\n" +
"6.3,3.4,5.6,2.4,virginica\n" +
"6.4,3.1,5.5,1.8,virginica\n" +
"6,3,4.8,1.8,virginica\n" +
"6.9,3.1,5.4,2.1,virginica\n" +
"6.7,3.1,5.6,2.4,virginica\n" +
"6.9,3.1,5.1,2.3,virginica\n" +
"5.8,2.7,5.1,1.9,virginica\n" +
"6.8,3.2,5.9,2.3,virginica\n" +
"6.7,3.3,5.7,2.5,virginica\n" +
"6.7,3,5.2,2.3,virginica\n" +
"6.3,2.5,5,1.9,virginica\n" +
"6.5,3,5.2,2,virginica\n" +
"6.2,3.4,5.4,2.3,virginica\n" +
"5.9,3,5.1,1.8,virginica\n";
List tableRead = rConnection.eval(
"read.csv(textConnection("" + inputIris + ""), header =
FALSE)").asList(); // 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();
String[] d5 = ((REXPVector) ((RList) tableRead).get(4)).asStrings();
// create data frame with data.REXP myDf =
REXP.createDataFrame(new RList(
new REXP[]
{
new REXPDouble(d1),
new REXPDouble(d2),
new REXPDouble(d3),
new REXPDouble(d4),
new REXPString(d5)
}));
// assign the data to a variable as was
suggested.rConnection.assign("boxMVariable", myDf);
// create a string command with that variable name.String
boxVariable = "boxM(boxMVariable [,-5], boxMVariable[,5]";
// try to execute the command...
// FAILS with org.rosuda.REngine.Rserve.RserveException: eval
failed, request status: R parser: input incomplete>>>> FAILS !
>>>> REXP theBoxMResult = rConnection.eval(boxVariable); <<<<
FAILS <<<<<
sent from ProtonMail <https://protonmail.com>, Swiss-based
encrypted email.
[[alternative HTML version deleted]]
------------------------------------------------------------------------
R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list