From dtemplelang at ucdavis.edu  Sun Oct 29 14:56:42 2017
From: dtemplelang at ucdavis.edu (Duncan Temple Lang)
Date: Sun, 29 Oct 2017 13:56:42 +0000
Subject: [Rd] Cannot Compute Box's M (Three Days Trying...)
In-Reply-To: <yBJfX4WjevNGyZ5SgHYCo6jzpWa0eniZt751IWhfzVnyh1WH1QiaGGohK3Q0D_rHbHsPTmXL9E7laTfz_wBkgBL-T2jRxipDY3Nz0J97iTM=@protonmail.com>
References: <yNSrSEBSEthk1cJc2W6y3M50LXPWIRpFNyUtLE8yIZMb4guTLWuQi9XjWd4MHnt5vxOZAK1bO32QWqqM26bRU_XpiYnip5jDiyjKWUKIH7w=@protonmail.com>
 <3e5b4dc9-1b9a-4c63-a929-82a127856dbe@gmail.com>
 <P6V3IIqCfJ4SUFtNl9ML3Wmo2cvnL50vlzlUJdvRaAj106MjIojw5ITRt5ZQdkeOa9rnyS6HTxRgg7SUwmPY4CqGPbQFWqYEKCTr_yDVZdM=@protonmail.com>
 <abfb1feb-1da9-8c88-ceb5-98cef28ef406@gmail.com>
 <rl0BFmHLQl4yweaOtoWaJJEScu0VetftcUuusTtgU1qjAdU-8pgrnohMfnzvJQZTY2jPjjraq6xgDDAlxfHHZunKbfGydZILJQ8xk4g0IWc=@protonmail.com>
 <ee03e49f-9c97-5e34-d12e-7623effcf062@gmail.com>
 <9BD27QZMzsNhYUSXQNpmzB6M1_eswp75Vyk6vgZ67jKV3Mf8H3ji_fE_YVPRSOl9Pb7XZDy1nfJCHyqt5J8hzVCzg9JxsJ-piLcIeu_7JZ4=@protonmail.com>
 <abe44eb4-e08a-087a-1870-dc73d1e59da4@gmail.com>
 <3vTUHD1PtBDruYfNDtqh8Aom_SVM7c5CwgImGeBOfwq5N1z329qNFlNLnj9dL1NBUJExFwkQmTaBHYy88hXIdWhd4uiamMHFlqKs06TccYU=@protonmail.com>
 <ae21b1c0-7c3b-d244-46e7-5a039e21296b@gmail.com>
 <yBJfX4WjevNGyZ5SgHYCo6jzpWa0eniZt751IWhfzVnyh1WH1QiaGGohK3Q0D_rHbHsPTmXL9E7laTfz_wBkgBL-T2jRxipDY3Nz0J97iTM=@protonmail.com>
Message-ID: <CABQ6xNYj9SA28p7ku9m0DK+63=RJ+Gvqe=sKLvp5kBQgp2s+1g@mail.gmail.com>

The SJava package from 18 years  ago did (does) have bidirectional calls
from R to Java and Java to R. So you are not pushing
the interface somewhere it doesn't want to go.   But you are going about it
with strings and R syntax which is a much less powerful approach
than working with actual objects and function calls, and as you are finding
out, very cumbersome.   And it helps to know both R and Java well.
You might take a look at the SJava or rJava packages and see how they do
this. But you have to do your own homework first before asking questions
you can answer yourself.

Best,
 Duncan (TL)


On Sun, Oct 29, 2017 at 6:01 AM Morkus via R-devel <r-devel at r-project.org>
wrote:

> 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.duncan at gmail.com
> > To: Morkus <morkus at protonmail.com>
> > r-devel at r-project.org <r-devel at 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
-- 
Duncan Temple Lang
Director, Data Science Initiative
Professor of Statistics

	[[alternative HTML version deleted]]



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