I wish to use a different version of R than what is provided by Mathematica 9. For example, I want to use the Macports version of R, where R_HOME is /opt/local/lib/R.

When I type:

InstallR["RHomeLocation" -> "/opt/local/lib/R"]

I get the error:

InstallR::fail: Failed to install R. 
The following error was encountered: Unable to load dynamic libraries >>

(I tried to doctor up my ~/.MacOSX/environment.plist with DYLD_LIBRARY_PATH, but no luck.)

  • $\begingroup$ I'm also wondering if it is (will) be possible to update the internal R that gets downloaded from WRI to a later version (currently it's 2.14 while the latest R is 2.15). Once we install it using InstallR[], are we stuck with a particular version? $\endgroup$
    – Szabolcs
    Commented Nov 29, 2012 at 3:23
  • $\begingroup$ Originally I hoped that this option would work on all platforms. My initial tests indicated that it did. I had to then narrow this down to Windows for the time being, since problems on Linux and Mac were detected. This is a high-priority issue for RLink, so I hope to have more to say soon enough. $\endgroup$ Commented Nov 29, 2012 at 9:28
  • 1
    $\begingroup$ @Szabolcs Yes, the users are stuck with that version until we update the paclets. But I hope that the option of using own version of R will be working on other (than Windows) platforms reasonably soon, which should mitigate this situation. $\endgroup$ Commented Nov 29, 2012 at 12:08
  • $\begingroup$ For Linux folks: at least on some flavors of Linux, it has been reported that RLink works fine with the stand-alone R distribution. $\endgroup$ Commented Nov 29, 2012 at 17:45
  • 1
    $\begingroup$ Take a look at the first code block under "Examples" here. This works on my OS X 10.8.3 machine with R 3.0.1, but I heard it does not work on all systems. I am using the CRAN version of R, not the MacPorts version (is there good reason to use the MacPorts version?). Does it work for you? $\endgroup$
    – Szabolcs
    Commented May 28, 2013 at 20:43

1 Answer 1


The documentation says, and I quote,

Using Your Own R Distribution (Windows only)

On Windows, it is currently possible for you to use your own R distribution with RLink, which may have a number of advantages in certain circumstances. For example, you already have a customized R distribution that you would like to continue using for everything, including work with Mathematica/*RLink*. Or, you would like to install extra packages.

So, this might be possible on Windows but not on other systems.

  • $\begingroup$ I would almost think that it would be easier under Mac/Linux. Meh. $\endgroup$
    – Eric Brown
    Commented Nov 29, 2012 at 1:46
  • 5
    $\begingroup$ @OleksandrR. Oh no, if only you knew how much time was spent to actually make this work for the R version that comes with RLink, on Linux and Mac - this took the majority of time for RLink development. I was of course building R on both Linux and Mac from sources, and doing a whole lot more to make the default R coming with RLink work without setting any env. variables. For external versions of R, it was just unfortunate that some problems with this were detected late in the develpoment, so I had no time to fix that and had to restrict this to Windows only, for the time being. $\endgroup$ Commented Nov 29, 2012 at 9:33
  • $\begingroup$ @LeonidShifrin sorry to hear that; it sounds like you had a really bad time with this! Good that you persisted, though--this seems to be the first time that WRI has really even officially acknowledged the existence of what could be seen as a competitor, let alone building comprehensive support for it into Mathematica. A major achievement on your part! $\endgroup$ Commented Dec 1, 2012 at 19:31
  • $\begingroup$ @OleksandrR. Thanks! Re: bad times - one of the problems for me was that as a programmer, I am self-taught, and most of my life I was doing math / physics which did not involve any coding at all. So, some things which people with the proper CS / coding background would know or sort out quite fast, were taking me long to get resolved. But, I am getting better (I hope :)). Re: competition ackowledgement by WRI - well, I made my position on that clear to other people involved in M/R relationship assessment, but whether this had any impact on the final decision in that direction, I have no idea. $\endgroup$ Commented Dec 1, 2012 at 20:31
  • $\begingroup$ @OleksandrR thanks for letting us know that it is possible. Is it possible to know how it is possible? $\endgroup$ Commented Feb 9, 2021 at 20:42

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