How do I InstallR on OS X to use my already installed and configured R?

Simply using

InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources"]

results in

InstallR::nopaclet: Could not find RLink runtime installed. Please use RLinkResourcesInstall to install it

How do I connect Mathematica to my installed R? Do I have to install a separate R for Mathematica?

  • $\begingroup$ Note: "/Library/Frameworks/R.framework/Resources" there is what R.home() reports. $\endgroup$
    – orome
    Mar 10, 2014 at 13:42
  • $\begingroup$ @Szabolcs Sorry, I'm probably missing something. I followed all the instructions. My R version seems ok. But I have the following error: Needs::nocont: "Context "IGraphR` was not created when Needs was evaluated." But IGraphR.m is in the right folder (the one opened by SystemOpen@FileNameJoin[{$UserBaseDirectory, "Applications"}]) $\endgroup$
    – sam84
    Apr 8, 2014 at 8:20
  • $\begingroup$ @sam84 If IGraphR.m is really in the right folder, and you get this message, then you don't have the correct IGraphR.m file. Try downloading it again from here $\endgroup$
    – Szabolcs
    Apr 8, 2014 at 13:54
  • $\begingroup$ @Szabolcs yes, now it works. Thanks! $\endgroup$
    – sam84
    Apr 9, 2014 at 7:06

1 Answer 1


Try like this in a fresh kernel:


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

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

Update: With Mathematica 10.0.1 (but not 10.0.0), use

InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources", "RVersion" -> 3]; (* for M 10.0.1 *)

This works if you are using the R distribution from http://www.r-project.org/, but if I recall correctly some people said it didn't work with some other R distributions (e.g. MacPorts's R). I only tried with the official R.

To check that you are indeed running with the chosen version of R, evaluate


which on my system returns {"R version 3.0.3 (2014-03-06)"} (as I have R 3.0.3).

I described this before here.

Note: With Mathematica 9.0.1 it is necessary to first make sure that RLink is set up and working with Mathematica's internal R distribution, as described in the user guide. Once that is done, an external R can be used as above. Otherwise InstallR might exit with an InstallR::nopaclet error.

  • $\begingroup$ I still get "InstallR::nopaclet: Could not find RLink runtime installed. Please use RLinkResourcesInstall to install it". (I am using the r-project distribution.) $\endgroup$
    – orome
    Mar 10, 2014 at 13:49
  • 1
    $\begingroup$ @raxacoricofallapatorius RLinkResourcesInstall uses the same paclet mechanism that is used e.g. for downloading the curated built-in data from Wolfram servers. This is not something external, it is part of the general strategy Mathematica uses to download its optional parts, or parts which change in time (such as data). The resulting paclet is installed into a special Paclets subdirectory inside $UserBaseDirectory, where also other packets are installed (mostly, data). The Java part of RLink comes as a part of the core RLink distro, which is a part of Mathematica distribution. $\endgroup$ Mar 10, 2014 at 14:57
  • 1
    $\begingroup$ @raxacoricofallapatorius Ok, I looked into the code, and I can see where this bug is coming from. Basically, indeed, the internal R distro is currently required to be installed, even when this is not strictly necessary. So, for now, it is probably easiest to just install the internal version. If you are very much against that, I could write a patch to bypass this and post it here in a comment, but it will be untested (no time now to test it), and things may get wrong in more than one place in such patch. $\endgroup$ Mar 10, 2014 at 15:30
  • 1
    $\begingroup$ @raxacoricofallapatorius No problem. Also, I feel sorry that RLink's current state prevents you and some others from using it in the way you'd like to. I do hope to have some dedicated time to improve it some time soon. $\endgroup$ Mar 10, 2014 at 17:12
  • 1
    $\begingroup$ @Szabolcs Thank you. Using the command R.Home() to retrieve the home directory and following your procedure to install RLink successfully. Thank you. $\endgroup$ Apr 7, 2016 at 8:10

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.