# InstallR on OS X with external R installation on 10.0.1.0

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 10.0.0.0. However when Mathematica was updated to 10.0.1.0, an error msg came out.

The commands that I issued were:

Needs["RLink"]
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

• 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. Sep 29, 2014 at 15:48
• 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 :)). Sep 29, 2014 at 16:16
• @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? Sep 29, 2014 at 19:34
• 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. Sep 29, 2014 at 20:28
• @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. Sep 29, 2014 at 23:51

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

Needs["RLink"]

SetEnvironment[
"DYLD_LIBRARY_PATH" ->
"/Library/Frameworks/R.Framework/Resources/lib"];

InstallR["RHomeLocation" ->
"/Library/Frameworks/R.framework/Resources",
"RVersion" -> "R-3.1.1"];

REvaluate["R.version.string"]

• 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!
– Dave
Aug 14, 2016 at 0:14
• 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
– 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.

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