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.

I'd like to run the R version installed in my Windows 7 system from within Mathematica 9 but when I execute the following command:

InstallR["RHomeLocation" -> "C:\\Program Files\\R\\R-2.14.2\\bin\\x64"]

I get the following error message:

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

Does anybody know how to fix this issue? Many thanks in advance

share|improve this question
1  
Try to set it to the home directory of R, not the directory containing the binaries (based on the RLink docs it should point there). –  Szabolcs Dec 5 '12 at 3:41
    
@Szabolcs Why don't you make that an answer? Because that's the only sensible answer there is. And if it fails, I really want to know about it. –  Leonid Shifrin Dec 5 '12 at 3:51
    
@Leonid I did that now. I didn't want to post it as an answer as I don't have Mathematica 9 on Windows at the moment so I couldn't test it. It was the first thing that came to mind though and checking the docs confirmed it. –  Szabolcs Dec 5 '12 at 4:51
    
I see that you have not Accepted answers to any of your questions. Have you found all the answers lacking, or are you unaware of this convention on StackExchange sites? –  Mr.Wizard Dec 5 '12 at 6:50
1  
I had the same problem, but it turned out that was because I was using R.2.10.1. After I installed R.2.14.0, InstallR["RHomeLocation" -> "C:/Program Files/R/R.2.14.0"] worked fine. It also worked with R.2.15.2. –  user4902 Dec 6 '12 at 1:40

1 Answer 1

up vote 4 down vote accepted

The "RHomeLocation" option must be set to the base directory of the R installation, not the directory containing the binaries. Please try to set it to C:\Program Files\R.

Quoting the docs:

You can specify the location by using the "RHomeLocation" option to InstallR, calling it as follows.

InstallR["RHomeLocation" -> "LocationOfYourRDistribution"]

The value of the option should correspond to the R_HOME variable you usually set for your R distribution, and point at the root of it.

share|improve this answer
    
Beware that at present, Mathematica 9 allows you to use your own R installation only on the Windows platform. On other platforms, you must use the R run-time supplied by Wolfram. (This is clearly documented, although disappointing.) –  murray Dec 5 '12 at 20:15
    
@murray Well, it has been reported that you can use external R on at least some flavors of Linux. I can't promise anything, but I hope to be able to address this issue for the 9.1 release. –  Leonid Shifrin Dec 6 '12 at 0:16
    
@Szabolcs Thanks a lot for your answer. After following it, everything is fine now. May I suggest that the Mathematica 9 documentation is updated to put a specific example instead of the generic "LocationOfYourRDistribution"? –  Ruben.Garcia Dec 6 '12 at 3:46
    
Unfortunately for some reason that solution does not work on my machine with Windows 7. I had just installed R from a mirror site and given the proposed InstallR["RHomeLocation" -> "C:\\Program Files\\R"] only to receive the follwing error message: InstallR::nopaclet: Could not find RLink runtime installed. Please use RLinkResourcesInstall to install it. How can that be? –  gwr Dec 22 '13 at 16:28
    
@gwr Does RLink work with the internal R that gets automatically downloaded the first time you use it? What if you just do Needs["RLink`"]; InstallR[]? –  Szabolcs Dec 22 '13 at 16:30

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.