2
$\begingroup$

I am trying to get Mathematica and R to look at the same workspace, but have failed thus far. The task is to produce variables that will be operated upon by either program while the current state of these also can be simultaneously read by both. The R documentation allows for specification of the workspace but I am only guessing at the correct Mathematica notation. Here is the code:

(*testing connectivity*)
Needs["RLink`"];
SetEnvironment["LD_LIBRARY_PATH" -> "~/bin/r/.RData"];
InstallR["RHomeLocation" -> "~/bin/r/.RData", "RVersion" -> 3];

I have also tried:

Needs["RLink`"];
SetEnvironment["LD_LIBRARY_PATH" -> "~/bin/r/.RData"];
InstallR["RHomeLocation" -> "/usr/lib/R", "RVersion" -> 3];

and various similar combinations.

Note that the first version points explicitly to the file used by R. I have tried opening the two programs in different order (Mathematica first... R first) - nothing works. While can see workspaces in both programs, the workspaces are different, containing different variables.

$\endgroup$
2
  • $\begingroup$ You can't use RHomeLocation with Linux Mathematica distribution. $\endgroup$
    – m0nhawk
    Feb 22, 2016 at 19:49
  • $\begingroup$ I'm not sure that this is possible at all ... can you share a single workspace between two separate R instances? If not, you cannot do this with RLink either. If you can do it with two R instances, please show how. $\endgroup$
    – Szabolcs
    Feb 22, 2016 at 19:58

1 Answer 1

1
$\begingroup$

If I understand your question, you want to have a Mathematica and an R window side by side and have them share variables.

This is asking to share the workspace between two separate R instances: have two independent R windows side by side share the same variables. As far as I know this is not possible, but there are partial solutions:

What is important to understand is that RLink is just running another instance of R in the background and it is this, and only this instance of R that Mathematica can communicate with.

So this is asking to make RLink's R instance communicate with a separate R instance, as in the links above.

If you are looking to communicate between two different instances of R, that would be a question unrelated to Mathematica, thus off topic here, but on-topic on sites like StackOverflow.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.