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

2017-10-25 Thread Morkus via R-devel
Hi all,

Using RConsole, it's easy to get data from the database that you can use in an 
R Command. Like this:

(Reference case)

irisQuery <- dbGetQuery(conn, "select * from iris")
boxM(irisQuery [,-5], irisQuery[,5])



(Actual case this posting is about)

Yet, if I'm getting that same (sample IRIS) data, say, in a web service 
possibly POSTED from a SQL command, that same data might look like this 
(portion of the included iris data set below). I'm thus not sure how to package 
the data so R likes it.

Example R-included IRIS data from SQL output:

5.1,3.5,1.4,0.2,setosa,
4.9,3,1.4,0.2,setosa,
4.7,3.2,1.3,0.2,setosa,
4.6,3.1,1.5,0.2,setosa,
5,3.6,1.4,0.2,setosa,

I've tried various combinations in code to achieve what's simple in RConsole, 
but I can't get R to accept my structure.

- I've tried just including the data in a string.
- I've tried wrapping the data with "data"
- I've tried wrapping the data with "data.frame" (as below).

Here's my latest attempt:

String tableRead = "data.frame(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)" ;

// using parseAndEval below to give me actual error R is sending...
REXP rResponseObject = 
rConnection.parseAndEval("try(eval("+tableRead+"),silent=TRUE)");
if (rResponseObject.inherits("try-error"))
{
 System.out.println("R Serve Eval Exception : "+rResponseObject.asString());
}
REXP boxMResult = rConnection.eval("boxM("+ tableRead+ "[,-5]," + tableRead + 
"[, 5])");  // FAILS <<



Error in the above case is:

Disconnected from the target VM, address: '127.0.0.1:51356', transport: 'socket'
org.rosuda.REngine.REngineException: eval failed, request status: R parser: 
syntax error
at org.rosuda.REngine.Rserve.RConnection.parseAndEval(RConnection.java:454)
at org.rosuda.REngine.REngine.parseAndEval(REngine.java:108)
at 
net.example.start_r_fromjava.RStatisticsExample.main(RStatisticsExample.java:151)

Does the POSTed data need to be in a different format or am I just not framing 
it correctly?

Would appreciate any tips on how to package table data that might come from a 
SQL Query passed to Java code.

Thanks very much in advance,

- M

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] How to represent two-dimensonal data in R?

2017-10-26 Thread Morkus via R-devel
I asked this question yesterday, but since I didn't receive any responses, I 
thought I would simply the question a bit and try again.

Basically, I'm getting a query result sent to a program. That data is just the 
rows and columns of a database table. Simple 2-D.

My (hopefully simple) question is how do I take that variable and put that 
two-dimensional data in a form I can then send to R?

Can R represent two-dimensional data when passed like that to a variable? I 
cannot find a single example, anywhere, that describes how to do it. :(

I've tried: "data", "data.frame", "table", the data by itself, etc.

Nothing works. I only get "eval" syntax errors.

Please advise with any suggestions.

Thanks again.

- M

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2017-10-26 Thread Morkus via R-devel
That's amazing! Thank you!!!

One follow up question, if that's OK?

If, instead of using hard-coded CSV, I read the CSV into a variable first, then 
it fails again with a parse error.

Code below.

So, if I read the CSV into a variable, do I need an additional wrapper method?

Seems like it should still work.

Thanks in advance for your reply.

 -M

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";

REXP irisData =rConnection.eval(
"read.csv(textConnection(" + inputIris + "), header = FALSE)");

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.

>  Original Message 
> Subject: Re: [Rd] How to create a table structure in Java code?
> Local Time: October 26, 2017 7:45 AM
> UTC Time: October 26, 2017 11:45 AM
> From: rh...@eoos.dds.nl
> To: r-devel@r-project.org
>
> I suspect that you are looking for something like:
>
> read.csv(textConnection(
> "5.1,3.5,1.4,0.2,setosa
> 4.9,3,1.4,0.2,setosa
> 4.7,3.2,1.3,0.2,setosa
> 4.6,3.1,1.5,0.2,setosa
> 5,3.6,1.4,0.2,setosa"
> ), header = FALSE)
>
> HTH,
> Jan
>
> On 25-10-17 12:50, Morkus via R-devel wrote:
>
>> Hi all,
>> Using RConsole, it's easy to get data from the database that you can use in 
>> an R Command. Like this:
>> (Reference case)
>> irisQuery <- dbGetQuery(conn, "select * from iris")
>> boxM(irisQuery [,-5], irisQuery[,5])
>> ---
>>
>> (Actual case this posting is about)
>> Yet, if I'm getting that same (sample IRIS) data, say, in a web service 
>> possibly POSTED from a SQL command, that same data might look like this 
>> (portion of the included iris data set below). I'm thus not sure how to 
>> package the data so R likes it.
>> Example R-included IRIS data from SQL output:
>> 5.1,3.5,1.4,0.2,setosa,
>> 4.9,3,1.4,0.2,setosa,
>> 4.7,3.2,1.3,0.2,setosa,
>> 4.6,3.1,1.5,0.2,setosa,
>> 5,3.6,1.4,0.2,setosa,
>> I've tried various combinations in code to achieve what's simple in 
>> RConsole, but I can't get R to accept my structure.
>>
>> - I've tried just including the data in a string.
>> - I've tried wrapping the data with "data"
>> - I've tried wrapping the data with "data.frame" (as below).
>>
>> Here's my latest attempt:
>> String tableRead = "data.frame(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)" ;
>> // using parseAndEval below to give me actual error R is sending...
>> REXP rResponseObject = 
>> rConnection.parseAndEval("try(eval("+tableRead+"),silent=TRUE)");
>> if (rResponseObject.inherits("try-error"))
>> {
>> System.out.println("R Serve Eval Exception : "+rResponseObject.asString());
>> }
>> REXP boxMResult = rConnection.eval("boxM("+ tableRead+ "[,-5]," + tableRead 
>> + "[, 5])"); // FAILS <<
>> ---
>>
>> Error in the above case is:
>> Disconnected from the target VM, address: '127.0.0.1:51356', transport: 
>> 'socket'
>> org.rosuda.REngine.REngineException: eval failed, request status: R parser: 
>> syntax error
>> at org.rosuda.REngine.Rserve.RConnection.parseAndEval(RConnection.java:454)
>> at org.rosuda.REngine.REngine.parseAndEval(REngine.java:108)
>> at 
>> net.example.start_r_fromjava.RStatisticsExample.main(RStatisticsExample.java:151)
>> Does the POSTed data need to be in a different format or am I just not 
>> framing it correctly?
>> Would appreciate any tips on how to package table data that might come from 
>> a SQL Query passed to Java code.
>> Thanks very much in advance,
>>
>> - M
>>
>> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
>> [[alternative HTML version deleted]]
>> ---
>>
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ---
>
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


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

2017-10-26 Thread Morkus via R-devel
Thanks! I just figured it out (thanks to "Beyond Compare") and was coming here 
to post back.

The boxM test doesn't work with that (now, finally working) REXP structure, but 
I probably now need to create a table or something and parse that structure.

So much fun! :)

Thanks again.

- M

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.

>  Original Message 
> Subject: Re: [Rd] How to create a table structure in Java code?
> Local Time: October 26, 2017 10:13 AM
> UTC Time: October 26, 2017 2:13 PM
> From: simon.urba...@r-project.org
> To: Morkus 
> Jan van der Laan , r-devel@r-project.org 
> 
>
> You are entering the quoting hell - you are missing quotes and escapes for 
> \n. it would be much more reasonable to use the rConnection.assign method 
> instead of pasting any content through the parser.
>
> Cheers,
> Simon
>
>> On Oct 26, 2017, at 9:59 AM, Morkus via R-devel r-devel@r-project.org wrote:
>> That's amazing! Thank you!!!
>> One follow up question, if that's OK?
>> If, instead of using hard-coded CSV, I read the CSV into a variable first, 
>> then it fails again with a parse error.
>> Code below.
>> So, if I read the CSV into a variable, do I need an additional wrapper 
>> method?
>> Seems like it should still work.
>> Thanks in advance for your reply.
>> -M
>> 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";
>> REXP irisData =rConnection.eval(
>> "read.csv(textConnection(" + inputIris + "), header = FALSE)");
>> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
>>
>>>  Original Message 
>>> Subject: Re: [Rd] How to create a table structure in Java code?
>>> Local Time: October 26, 2017 7:45 AM
>>> UTC Time: October 26, 2017 11:45 AM
>>> From: rh...@eoos.dds.nl
>>> To: r-devel@r-project.org
>>> I suspect that you are looking for something like:
>>> read.csv(textConnection(
>>> "5.1,3.5,1.4,0.2,setosa
>>> 4.9,3,1.4,0.2,setosa
>>> 4.7,3.2,1.3,0.2,setosa
>>> 4.6,3.1,1.5,0.2,setosa
>>> 5,3.6,1.4,0.2,setosa"
>>> ), header = FALSE)
>>> HTH,
>>> Jan
>>> On 25-10-17 12:50, Morkus via R-devel wrote:
>>>
>>>> Hi all,
>>>> Using RConsole, it's easy to get data from the database that you can use 
>>>> in an R Command. Like this:
>>>> (Reference case)
>>>> irisQuery <- dbGetQuery(conn, "select * from iris")
>>>> boxM(irisQuery [,-5], irisQuery[,5])
>>>>
>>>> (Actual case this posting is about)
>>>> Yet, if I'm getting that same (sample IRIS) data, say, in a web service 
>>>> possibly POSTED from a SQL command, that same data might look like this 
>>>> (portion of the included iris data set below). I'm thus not sure how to 
>>>> package the data so R likes it.
>>>> Example R-included IRIS data from SQL output:
>>>> 5.1,3.5,1.4,0.2,setosa,
>>>> 4.9,3,1.4,0.2,setosa,
>>>> 4.7,3.2,1.3,0.2,setosa,
>>>> 4.6,3.1,1.5,0.2,setosa,
>>>> 5,3.6,1.4,0.2,setosa,
>>>> I've tried various combinations in code to achieve what's simple in 
>>>> RConsole, but I can't get R to accept my structure.
>>>>
>>>> - I've tried just including the data in a string.
>>>> - I've tried wrapping the data with "data"
>>>> - I've tried wrapping the data with "data.frame" (as below).
>>>>
>>>> Here's my latest attempt:
>>>> String tableRead = "data.frame(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)" ;
>>>> // using parseAndEval below to give me actual error R is sending...
>>>> REXP rResponseObject = 
>>>> rConnection.parseAndEval("try(eval("+tableRead+"),silent=TRUE)");
>>>> if (rResponseObject.inherits("try-error"))
>>>> {
>>>> System.out.println("R Serve Eval Exception : "+rResponseObject.asString());
&g

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

2017-10-26 Thread Morkus via R-devel
ALMOST THERE

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! :)



ENTIRE CODE SNIPPET:

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" +
"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" +
"6.1,2.6,5.6,1.4,virginica";

(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]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] How to do a "Box's M" Test with

2017-10-27 Thread Morkus via R-devel
Trying to get past a frustrating error to do a "simple" Box's M test using Java.

The Box's M test says it will work with a data.frame.

Here's the setup code:

REXP myDf = REXP.createDataFrame(new RList(
new REXP[]
{
new REXPDouble(d1),
new REXPDouble(d2),
new REXPDouble(d3),
new REXPDouble(d4),
new REXPInteger(d5)
}));

Here's the call:

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

But, I keep getting syntax errors.

If this code isn't right, how do you build a data.frame R will like?  No 
examples I can find, anywhere.

Not sure what to try next. I've tried just sending a string with everything 
commented, but nothing I've tried works.

Can anyone please suggest something to try?

Thanks in advance.

- M

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] How to do a "Box's M" Test with

2017-10-27 Thread Morkus via R-devel
Thanks for the ideas. I'll keep trying...

Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.

>  Original Message 
> Subject: Re: [Rd] How to do a "Box's M" Test with
> Local Time: October 27, 2017 8:50 AM
> UTC Time: October 27, 2017 12:50 PM
> From: murdoch.dun...@gmail.com
> To: Morkus , r-devel@r-project.org 
> 
>
> On 27/10/2017 8:10 AM, Morkus via R-devel wrote:
>
>> Trying to get past a frustrating error to do a "simple" Box's M test using 
>> Java.
>> The Box's M test says it will work with a data.frame.
>> Here's the setup code:
>> REXP myDf = REXP.createDataFrame(new RList(
>> new REXP[]
>> {
>> new REXPDouble(d1),
>> new REXPDouble(d2),
>> new REXPDouble(d3),
>> new REXPDouble(d4),
>> new REXPInteger(d5)
>> }));
>> Here's the call:
>> REXP boxMResult = rConnection.eval( "boxM(" + myDf+ "[,-5], " + myDf + " [, 
>> 5])");
>>
>> I don't really know the R Java interface, but this doesn't make sense.
>> You are pasting an REXP object myDf into a string to evaluate. It would
>> make sense to assign that dataframe object to an R variable, and paste
>> the name of that variable into your expression, or to construct a
>> language object containing the dataframe object, but I don't know how to
>> do those things.
>>
>> Duncan Murdoch
>> But, I keep getting syntax errors.
>> If this code isn't right, how do you build a data.frame R will like? No 
>> examples I can find, anywhere.
>> Not sure what to try next. I've tried just sending a string with everything 
>> commented, but nothing I've tried works.
>> Can anyone please suggest something to try?
>> Thanks in advance.
>>
>> - M
>>
>> Sent from [ProtonMail](https://protonmail.com), Swiss-based encrypted email.
>> [[alternative HTML version deleted]]
>> ---
>>
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-27 Thread Morkus via R-devel
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\

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-28 Thread Morkus via R-devel
Hi Bill,

Thanks for catching that. However, the problem remains.

If I use R debugging code with the rResponseObject below, I get a maybe better 
error, but it still doesn't make sense.

This is the actual error R is throwing:

Error in `[.data.frame`(boxMVariable, , -5) : undefined columns selected

Does this error make sense?

Please reply. :)

Thanks in advance.

---



REXP rResponseObject = rConnection.parseAndEval("try(eval(" + boxVariable+ 
"),silent=TRUE)");
if (rResponseObject.inherits("try-error"))
{
System.out.println("R Serve Eval Exception : " + rResponseObject.asString());
}

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 4:00 PM
> UTC Time: October 27, 2017 8:00 PM
> From: wdun...@tibco.com
> To: Morkus 
> r-devel@r-project.org 
>
> Does it work if you supply the closing parenthesis on the call to boxM?  The 
> parser says the input is incomplete and a missing closing parenthesis would 
> cause that error..
>
> // 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 <<<<<
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Fri, Oct 27, 2017 at 12: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,versicol

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-28 Thread Morkus via R-devel
I'm not sure what you mean. Could you please be more specific?

If I print the string, I get:  boxM(boxMVariable[, -5], boxMVariable[, 5])

>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.dun...@gmail.com
> To: Morkus , r-devel@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

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-28 Thread Morkus via R-devel
Thanks Duncan. Awesome ideas!

I think we're getting closer!

I tried what you suggested and got a possibly better error...
.
.
.
rConnection.assign("boxMVariable", myDf);

String resultBV = "str(boxMVariable)";   // your suggestion.

RESULTING ERROR:

Error in format.default(nam.ob, width = max(ncn), justify = "left") :  invalid 
'width' argument

(No idea what this means).

For testing, I'm using the same standard IRIS dataset as the Box's M 
documentation shows in biotools:

Examples

data(iris)

boxM(iris[, -5], iris[, 5])

---

Now, in the debugger, the built values of myDf are these:

myDf = {org.rosuda.REngine.REXPGenericVector@562} 
"org.rosuda.REngine.REXPGenericVector@17d99928+[5]”


▼ payload = {org.rosuda.REngine.RList@566} size = 5
► 0 = {org.rosuda.REngine.REXPDouble@570} 
"org.rosuda.REngine.REXPDouble@6fffcba5[150]"
► 1 = {org.rosuda.REngine.REXPDouble@571} 
"org.rosuda.REngine.REXPDouble@34340fab[150]”
► 2 = {org.rosuda.REngine.REXPDouble@572} 
"org.rosuda.REngine.REXPDouble@2aafb23c[150]"
► 3 = {org.rosuda.REngine.REXPDouble@573} 
"org.rosuda.REngine.REXPDouble@2b80d80f[150]”
► 4 = {org.rosuda.REngine.REXPString@574} 
"org.rosuda.REngine.REXPString@3ab39c39[150]”

Does this help?

Please let me know what else I can try.

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 28, 2017 6:48 AM
> UTC Time: October 28, 2017 10:48 AM
> From: murdoch.dun...@gmail.com
> To: Morkus 
> r-devel@r-project.org 
>
> 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
>
> -
>
> 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.dun...@gmail.com
>>> To: Morkus mor...@protonmail.com, r-devel@r-project.org
>>> r-devel@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,
>>> 

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-28 Thread Morkus via R-devel
Double@2b80d80f[150]”
>> ► 4 = {org.rosuda.REngine.REXPString@574}
>> "org.rosuda.REngine.REXPString@3ab39c39[150]”
>> Does this help?
>> Please let me know what else I can try.
>> 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 28, 2017 6:48 AM
>>> UTC Time: October 28, 2017 10:48 AM
>>> From: murdoch.dun...@gmail.com
>>> To: Morkus mor...@protonmail.com
>>> r-devel@r-project.org r-devel@r-project.org
>>> 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
>>>
>>> -
>>>
>>> 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.dun...@gmail.com <mailto:murdoch.dun...@gmail.com>
>>> To: Morkus mor...@protonmail.com
>>> <mailto:mor...@protonmail.com>, r-devel@r-project.org
>>> <mailto:r-devel@r-project.org>
>>> r-devel@r-project.org <mailto:r-devel@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" +
>

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-29 Thread Morkus via R-devel
rdoch.dun...@gmail.com>
>>>  To: Morkus mor...@protonmail.com <mailto:mor...@protonmail.com>
>>>  r-devel@r-project.org <mailto:r-devel@r-project.org>
>>>  r-devel@r-project.org <mailto:r-devel@r-project.org>
>>>  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.dun...@gmail.com
>>>  <mailto:murdoch.dun...@gmail.com> To: Morkus
>>>  mor...@protonmail.com <mailto:mor...@protonmail.com>,
>>>  r-devel@r-project.org <mailto:r-devel@r-project.org>
>>>  r-devel@r-project.org <mailto:r-devel@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,seto

Re: [Rd] Cannot Compute Box's M (Three Days Trying...)

2017-10-29 Thread Morkus via R-devel
Hey Duncan,

Since Java is the #1 language and R is extremely popular, I think the most 
telling thing is that nobody on the "R-devel" forum (where people do 
"programming with R") is doing R and Java like I'm doing: calling R from Java 
and passing data structures.

So it appears I'm clearly pushing R somewhere it doesn't want to go. And, the 
boxM issue is more or less debug-proof at this moment.

Perhaps I'll need to off-shore this issue for resolution for a few hundred 
bucks? I'm at the point now where I probably need to just pay somebody to get 
this crazy BoxM thing working! :(

Thanks again,

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 29, 2017 7:45 AM
> UTC Time: October 29, 2017 11:45 AM
> From: murdoch.dun...@gmail.com
> To: Morkus 
> r-devel@r-project.org 
>
> On 29/10/2017 7:26 AM, Morkus wrote:
>
>> Thanks Duncan. I can't tell you how helpful all your terrific replies
>> have been.
>> I think the biggest surprise is that nobody appears to be using Java and
>> R together like I"m trying to do. I suppose it should be a surprise
>> since there are no books on the subject and almost no technical
>> documentation other than a few sites here and there.
>> ---
>>
>> I originally had the "int" as the return type for the factors, but that
>> didn't make any difference.
>> So, let me ask you. What I can get working is calling an R Script from
>> Java. Literally opening the ".R" file and reading it line by line and
>> evaluating it. That works. Is there any reason why that's not a viable
>> way to go?
>>
>> I can't answer this very specifically, because it depends so much on
>> your circumstances. But why bother with the file system at all?
>> Presumably if you can read a string, you can construct the same string
>> within your Java program (perhaps as a literal string, perhaps by
>> building it from local variables).
>> The one thing I don't know how to do is pass a parameter to an RScript
>> from Java. Is it possible to pass a parameter to an RScript from Java?
>> If I can pass a parameter to an RScript, then it's not static and I
>> could use it as a "function" to call for different values.
>> Look forward to your reply.
>>
>> I can't really answer that question, since I have no experience at all
>> in calling R from Java. But if you want to pass a parameter named "x"
>> with value 123 from Java to R, why not just construct and evaluate the
>> statement "x <- 123"?
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Renjin?

2017-10-29 Thread Morkus via R-devel
Hi All,

OK, in the "back to the drawing board" department, I found what looks like a 
much better solution to using R in Java. Renjin.

Looking at the docs and then trying a quick example, didn't quite work.

Of course I'm missing something.

Although I'm telling the engine to require ("biotools") just like I would in R 
itself, when I get to the line of code that does the actual call

engine.eval("boxMResult <- boxM(inputIris [,-5], inputIris[,5])");

Then, I get:

Exception in thread "main" org.renjin.eval.EvalException: could not find 
function 'boxM'

Am I using Renjin as intended? Biotools is installed in R and works fine from 
RStudio.

I didn't see any examples in the docs (please excuse if I missed) that bring in 
any libraries.

Entire Java source below.

Thanks in advance,



public class RCallerExample{
public static void main(String[] args)
{
// create a script engine manager:RenjinScriptEngineFactory factory = new 
RenjinScriptEngineFactory();
// create a Renjin engine:ScriptEngine engine = factory.getScriptEngine();

try{
engine.eval("require(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