RLink Java(TM) platform has stopped working

Short Answer

R cannot handle expressions that are nested very deeply. You will have to find a way to simplify your expressions.

Long Answer

I can reproduce the crash on V9 under Windows 7 64-bit with a simpler setup. Start with these definitions:

Needs["RLink`"]
InstallR[];

expr[depth_] := "function(x){"~~Nest["1+("~~#~~")"&, "x", depth]~~"}"

This will work:

REvaluate[expr[48]]

But this will not:

(* WARNING: this causes JLink/Java to crash!! *)
REvaluate[expr[49]]

And neither will this (after restarting JLink/RLink):

(* WARNING: this causes JLink/Java to crash!! *)
com`wolfram`links`rlink`RLinkInit`getRExecutor[]@eval[expr[50]]

If I evaluate the following expression (expr[50]) directly in Rgui, I get a runtime exception:

function(x){
1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(
1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(
1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(
1+(1+(1+(1+(1+(x)))))))))))))))))))))))))))))
)))))))))))))))))))))
}

# Error: contextstack overflow at line 1

My guess is that this is not a bug in RLink directly -- I suspect that the JRI native library has a very nasty problem trying to handle such error conditions.


Ok,just reporting that an easy way around this problem is using ExpandAll command in mathematica,so you get rid of nested parentheses

Tags:

Rlink