4

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

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Ruben Garcia
  • 637
  • 3
  • 9
  • 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 05 '12 at 03: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 05 '12 at 03: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 05 '12 at 04: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 05 '12 at 06: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. –  Dec 06 '12 at 01:40

1 Answers1

4

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.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
  • 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 05 '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 06 '12 at 00: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 06 '12 at 03: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
  • @Szabolcs That works fine as I just tested following your post. I seems to be an issue with releases 3.x.x of R as this thread indicates maybe: RLink and R v3.0.1? – gwr Dec 22 '13 at 17:01
  • @gwr It looks like you found your answer, even if it's not what we hoped for ... I should have mentioned that I am not using Windows any more so I cannot actually test this. I do use R 3.0.1 with RLink on Mac. – Szabolcs Dec 22 '13 at 17:03