2
$\begingroup$

I can't install R on Windows 10. I tried some solutions that I found on the Internet, but they did not help.

Needs["RLink`"]
JLink`UninstallJava[]
InstallR[
  "RHomeLocation" -> "X:\\Program Files\\R\\R-3.5.1", 
  "NativeLibLocation" -> 
  "X:\\Program Files\\R\\R-3.5.1\\library\\rJava\\jri\\x64"]

During evaluation of the above, I get

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

$Failed

$\endgroup$
  • $\begingroup$ Wolfram support will likely be better able to help than will we. Have you tried contacting them? $\endgroup$ – b3m2a1 Feb 11 at 23:54
  • $\begingroup$ Yes, but I haven't received an answer yet. $\endgroup$ – Aleksei Zhidkov Feb 12 at 7:14
  • $\begingroup$ There are actually two issues here: incompatibility with the more recent versions of R, and the bug that requires to call InstallR[] twice at first, for every session. Both have been fixed for 12.0. For the dll issues, you can use the answer here for the workaround. You will need to go to R console (for your R distro), and call install.packages("rJava") from there. Next, go to installed rJava package and locate there jri.dll in JRI folder, for your architecture (64 bit, I presume)... $\endgroup$ – Leonid Shifrin Feb 12 at 11:19
  • $\begingroup$ Then use that location, for the setting of "NativeLibLocation" (look at the answer I linked). That should take care of the library issue. As to the other one, you will need to call InstallR[...] followed immediately by UninstallR[], and then InstallR[] again, at the start of the R session. After that, everything should work. Let me know if that does not work for you, I will look closer (don't have 11.3 installed at the moment). Sorry for this state of affairs, I should've fixed these issues earlier. $\endgroup$ – Leonid Shifrin Feb 12 at 11:22
  • 1
    $\begingroup$ @b3m2a1 "Wolfram support will likely be better able to help than will we. Have you tried contacting them?" - correct in general, but in this particular case this path will likely lead to me, unless they have these workarounds available. $\endgroup$ – Leonid Shifrin Feb 12 at 20:23
5
$\begingroup$

With the help of reading @szabolcs RLink link which has the following:

Unfortunately, with recent versions of Mathematica and R on macOS, occasionally the R runtime crashes on the first use of REvaluate, and the following message is shown: “Crash in low-level RLink component or in R runtime. Please reinstall RLink via InstallR”. After using InstallR[] a second time, RLink seems to work fine.

the following then seems to get things working for me on Windows 10 with Mathematica 11.3:

Needs["RLink`"]
InstallR["RHomeLocation" -> "c:\\Program Files\\R\\R-3.4.4"]
REvaluate["x = 6"]

(* REvaluate::crash: Crash in low-level RLink component or in R runtime.
   Please reinstall RLink via InstallR *)

InstallR["RHomeLocation" -> "c:\\Program Files\\R\\R-3.4.4"]

Now all subsequent RLink commands work.

$\endgroup$
  • $\begingroup$ I tried this command, but "InstallR::fail: Failed to install R. The following error was encountered: Unable to load dynamic libraries". $\endgroup$ – Aleksei Zhidkov Feb 12 at 7:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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