1
$\begingroup$

Background

Yes, there have been a lot of questions on RLink (quite a few on just how to get it working or installing packages). However none directly address loading RLink on MacOS. Older questions Installing R packages using RLink on Mac OS X appear to somehow have RLink working.

When some posts have users with MacOS dealing with difficulty due to RLink, Szabolcs' post on Setting up RLink for Mathematica has become the default response to these errors. (see here, here, etc)

Namely, it states (for MacOS):

Needs["RLink`"]
SetEnvironment["DYLD_LIBRARY_PATH" -> "/Library/Frameworks/R.framework/Resources/lib"];
InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources", "RVersion" -> 3]

However, it is stated clearly in the documentation for InstallR:

"RHomeLocation" Automatic location of the root of an external R distribution (currently Windows only)

Running the SetEnvironment command does not seem to cause any errors.

Another previous question Does mathematica 9 on mac depend on these dynamic libraries? has an answer which states:

none of the direct dependencies lies under /usr/local

which, in the terminal, which R is under:/usr/local/bin/R. Honestly, I do not even know if that is relevant.

Question

Does anyone have a fool-proof solution for using RLink on MacOS?

$\endgroup$
12
  • $\begingroup$ RHomeLocation is not officially supported on OS X. That's why I wrote that guide. It's basically a hack. If you scroll to the bottom, you will find notes on how to get it working on OS X 10.11 and later—you need to do some extra work on that version because of the system integrity protection feature. Have you tried following the instructions there? If yes, what went wrong? To be frank, I have not used RLink in a long time. $\endgroup$
    – Szabolcs
    Feb 17, 2017 at 8:38
  • $\begingroup$ @Szabolcs I looked at the directory and that file libjri.jnilib does not exist... $\endgroup$
    – SumNeuron
    Feb 17, 2017 at 8:44
  • $\begingroup$ Have you looked within subfolders of that folder? There is a single subfolder there in v11, so I don't think it's hard to find if you look a bit ... In recent M versions it seems to have been moved. As I said, this is not supported, so there will not be a "foolproof" solution. You can write to Wolfram Support and ask them to supports external R on OS X. $\endgroup$
    – Szabolcs
    Feb 17, 2017 at 9:09
  • $\begingroup$ I just tested the instructions on my page with version 11.0.1, OS X 10.12 and R 3.3.2 (r-project.org distribution). It works fine. $\endgroup$
    – Szabolcs
    Feb 17, 2017 at 10:32
  • $\begingroup$ @Szabolcs ok so then it is a matter of me not having the file? $\endgroup$
    – SumNeuron
    Feb 17, 2017 at 10:37

0

Your Answer

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

Browse other questions tagged or ask your own question.