I had no problem to follow the instructions given at InstallR on OS X with external R installation to get an external R working with Mathematica However when Mathematica was updated to, an error msg came out.

The commands that I issued were:

SetEnvironment["DYLD_LIBRARY_PATH" -> "/Library/Frameworks/R.framework/Resources/lib"];
InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources"];

The error msg is

InstallR::rundetctd: "Failed to detect the R version from the specified path to R home directory. Try using the "RVersion" option to specify the R version explicitly"

I have checked InstallR options and did not find "RVersion" there. Am I missing something?

Many thanks

  • $\begingroup$ This might be a bug (or, rather, the defaults not set quite right). What version of external R do you use? Generally, you can fix this by providing it explicitly, as indicated in the error message: try adding an explicit option "RVersion" -> "R-3.1.0", for example. $\endgroup$ Sep 29, 2014 at 15:48
  • $\begingroup$ Yes, I forgot to mention, that "RVersion" option has not yet been documented (but neither has the use of RLink with external R on Mac OS X :)). $\endgroup$ Sep 29, 2014 at 16:16
  • $\begingroup$ @Leonid Shifrin - Many thanks for the reply. I am running R version 3.1. /Library/Frameworks/R.framework/Version shows that I have a dir called 3.1, 3.0 and Current. When I issue the command InstallR["RHomeLocation"->"/Library/Frameworks/R.framework/Resources","RVersion"->"3.1"] the same error msg comes out. "RVersion" -> "R-3.1.0" sends the same msg too. Any thoughts? $\endgroup$
    – Ed Mendes
    Sep 29, 2014 at 19:34
  • 1
    $\begingroup$ I'll have to check this. Will get back when I'm done, perhaps one or two days. We did check this before release, and it worked. So, I'll have to look closer and reproduce this. In the mean time, out of curiosity, try "RVersion"->"3.1.1" - which is what we used. If it works, please ping me here (it anyway looks like a bug, but it would be easier to localize). Thanks. $\endgroup$ Sep 29, 2014 at 20:28
  • $\begingroup$ @Leonid Shifrin. Many many thanks. The output of InstallR with 3.1.1 is InstallR::fail: Failed to install R. The following error was encountered: Unable to load dynamic libraries >>. The error mgs is different! I must be doing something wrong. $\endgroup$
    – Ed Mendes
    Sep 29, 2014 at 23:51

2 Answers 2


Here are the commands I used, which worked for me (of course, I am using R version 3.1.1):



InstallR["RHomeLocation" -> 
   "RVersion" -> "R-3.1.1"];

  • $\begingroup$ changed R.Framework to R.framework in first reference above. Tested with OS X version of R v 3.3.1 and Mathematica 11.0, worked successfully. Thx! $\endgroup$
    – Dave
    Aug 14, 2016 at 0:14
  • $\begingroup$ My above comment was for my installation on OS X version 10.10.5 . For installing on OS X version 10.11.6 I used the patch here: szhorvat.net/pelican/setting-up-rlink-for-mathematica.html with the small change I noted that seems necessary for Mathematica 11.0 $\endgroup$
    – Dave
    Aug 14, 2016 at 3:58

I wrote a guide on using external R installations on various operating systems with various Mathematica versions. I intend to keep this up to date.

This is accompanied by a small package that automates using an external R.

As others mentioned, in your case all is needed is adding the option "RVersion" -> 3 to InstallR.

  • $\begingroup$ Thanks for this -- in particular, it solved my "Unable to load dynamic libraries" error under OSX El Capitan. $\endgroup$
    – Chris K
    Dec 28, 2015 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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