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

  • 1
    $\begingroup$ 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). $\endgroup$ – Szabolcs Dec 5 '12 at 3:41
  • $\begingroup$ @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. $\endgroup$ – Leonid Shifrin Dec 5 '12 at 3:51
  • $\begingroup$ @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. $\endgroup$ – Szabolcs Dec 5 '12 at 4:51
  • $\begingroup$ 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? $\endgroup$ – Mr.Wizard Dec 5 '12 at 6:50
  • 1
    $\begingroup$ 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. $\endgroup$ – user4902 Dec 6 '12 at 1:40

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.

  • $\begingroup$ 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.) $\endgroup$ – murray Dec 5 '12 at 20:15
  • $\begingroup$ @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. $\endgroup$ – Leonid Shifrin Dec 6 '12 at 0:16
  • $\begingroup$ @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"? $\endgroup$ – Ruben.Garcia Dec 6 '12 at 3:46
  • $\begingroup$ 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? $\endgroup$ – gwr Dec 22 '13 at 16:28
  • $\begingroup$ @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[]? $\endgroup$ – Szabolcs Dec 22 '13 at 16:30

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.