Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

$Failed
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?

share|improve this question
    
Note: "/Library/Frameworks/R.framework/Resources" there is what R.home() reports. –  raxacoricofallapatorius Mar 10 at 13:42
    
@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"}]) –  sam84 Apr 8 at 8:20
    
@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 –  Szabolcs Apr 8 at 13:54
    
@Szabolcs yes, now it works. Thanks! –  sam84 Apr 9 at 7:06

1 Answer 1

up vote 3 down vote accepted

Try like this in a fresh kernel:

Needs["RLink`"]

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

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

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

REvaluate["R.version.string"]

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.

share|improve this answer
    
I still get "InstallR::nopaclet: Could not find RLink runtime installed. Please use RLinkResourcesInstall to install it". (I am using the r-project distribution.) –  raxacoricofallapatorius Mar 10 at 13:49
    
You must install Mathematica's internal R first. Once that it working, you can use an external R like above. See my update. I assume this will install not only the internal R, but also some other code that's necessary for RLink to work. –  Szabolcs Mar 10 at 13:52
1  
@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. –  Leonid Shifrin Mar 10 at 14:57
1  
@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. –  Leonid Shifrin Mar 10 at 15:30
1  
@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. –  Leonid Shifrin Mar 10 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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