I'm trying to install RLink here.

Needs["RLink"]
InstallR[]


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


And then:

RSet["myVar",10]
JLinkJava::argx: Method named rPut defined in class com.wolfram.links.rlink.dataTypes.inTypes.RIntegerVectorInType was called with an incorrect number or type of arguments. The arguments, shown here in a list, were {myVar,$Failed}. >> REvaluate::err: General error in function RLinkPrivatewithRTemporaryVariables >> First::normal: Nonatomic expression expected at position 1 in First[$Failed]. >>
StringReplace::strse: String or list of strings expected at position 1 in StringReplace[StringTrim[First[$Failed]],RLinkFunctionHash12345[[~~DigitCharacter..~~]]:><function>]. >> RSet::puterr: Error putting the expression 10 into a variable myVar in R. The last error message issued by R was StringReplace[StringTrim[First[$Failed]],RLinkFunctionHash12345[[~~DigitCharacter..~~]]:><function>] >>
$Failed  It isn't java's fault. I've tried pointing JRELocation option of InstallR to different JREs, error stays the same. I'm on Ubuntu 12.04 64 bit. • What platform are you on, precisely (Ubuntu - which version? 64 bit). I will file a bug for this and will deal with this issue as soon as possible. One useful thing you can do to help us is to execute RLinkDevelopergetLog[] right after InstallR[] fails, and send the output to me (leonids@wolfram.com). – Leonid Shifrin Nov 29 '12 at 15:27 • @LeonidShifrin Done. – swish Nov 29 '12 at 15:41 • In the meantime, consider also installing the external R distribution and then try the "RHomeLocation" option, per @b.gatessucks answer. This may work. If you do try it, please share your results with us. Thanks. – Leonid Shifrin Nov 29 '12 at 16:00 ## 7 Answers I have R installed separately and can do : InstallR["RHomeLocation" -> "/usr/lib64/R"]  I am able to run the examples provided in the documentation. I use Fedora 17 64 bit. • That's good news, man! So, for at least some Linux flavors, RLink does work with an external R distribution. Thanks for sharing this. – Leonid Shifrin Nov 29 '12 at 15:56 • @Leonid My pleasure. It would be even better if I knew R. – b.gatessucks Nov 29 '12 at 16:05 • Do you need R for anything, at least potentially? – Leonid Shifrin Nov 29 '12 at 16:14 • @LeonidShifrin I might have to pick at least one between R and Python soon (for work). – b.gatessucks Nov 29 '12 at 16:15 • Actually it works, I'm sure I've tried it before but now it works somehow :). The only difference is that R is inside "/usr/lib/R". Some typo maybe... – swish Nov 29 '12 at 16:56 I also had this problem on Ubuntu 12.04, but this solution didn't help me. I think I've gotten it solved though. I suspect that several of my steps were unnecessary (or unnecessarily convoluted) but here goes: First, make the R launch script and binary installed by Mathematica executable. I don't know if Mathematica actually runs these, but it did allow me to test them.  cd ~/.Mathematica/Paclets/Repository/RLinkRuntime-Linux-x86-64-9.0.0.0/SystemFiles/Linux-x86-64/R/bin chmod +x R cd exec chmod +x R cd .. gedit R or whatever text editor. The launcher script had lots of references to "/Developer/leonids/" hardcoded into paths. I replaced the following lines: 04 R_HOME_DIR=/home/{my username}/.Mathematica/Paclets/Repository/RLinkRuntime-Linux-x86-64-9.0.0.0/SystemFiles/Linux-x86-64/R 35 R_SHARE_DIR="${R_HOME_DIR}/share"
37 R_INCLUDE_DIR="${R_HOME_DIR}/include" 39 R_DOC_DIR="${R_HOME_DIR}/doc"

After this, R still didn't work from the command line; it complained about not having libg2c.so.0. That's not available in any currently maintained Ubuntu distro, but I tracked down an RPM: compat-libf2c-34-3.4.6-9.x86_64.rpm. So,

sudo alien compat-libf2c-34-3.4.6-9.x86_64.rpm
sudo dpkg -i compat-libf2c-34-3.4.6-9.x86_64.deb

R continued to complain about missing libg2c.so.0. It turns out it was in the wrong place, because 64 bit Fedora and Ubuntu keep their libraries in different places.

sudo cp /usr/lib64/libg2c.* /usr/lib/

Voilà! R now works from the command line, and RLink works as well.

Incidentally, it looks like libg2c is basically deprecated now, so ideally, it would be removed as a dependency in favor of a more modern FORTRAN runtime, e.g. gfortran.

• Thanks a lot for this, I should've posted this information myself. A pity I only noticed this answer now, big +1. – Leonid Shifrin Oct 25 '13 at 17:41
• It might be simpler to just extract the files from the RPM and copy them to /usr/lib by hand (instead of converting to deb and installing it, then moving the files by hand). – Szabolcs Nov 8 '14 at 18:02

What I suspect is happening is that your flavor of Linux either lacks certain libraries which we considered standard, or has versions of those libraries which are in conflict with some of the ones we ship with the internal R distribution. Unfortunately, it is not easy to diagnose exactly which libraries are problematic, but I will try to follow up on this.

The situation with Linux is currently as follows: we tried our best to test on various Linux distributions, but the way RLink's default R distribution works is such that on some Linux distros there might be library version conflicts, since we had to augment the R distro with additional dependent libraries.

We did test on CentOS 5, and also on Ubuntu. I just re-tested and RLink works for me on Ubuntu 10.04 32 bit running on the virtual box (VMWare). And, it is almost certainly not Java, since RLink uses the JVM that comes with Mathematica. What we will do for Linux is to collect various problems like that, and try to resolve them to the best we can. However, some problems are inherent to Linux having many different flavors with somewhat different core libraries.

• @Leonard Shifrin: So it seems you have something to do with implementing RLink. In any case, please be aware that it's unfortunate that for Mac OS X an existing R installation cannot be used at present. In my department, e.g., most office machines provided for faculty are Macs. – murray Dec 6 '12 at 4:20
• @murray I am fully aware of that, thanks. There are some technical problems for Macs, hopefully they will be resolved soon, as I already mentioned. – Leonid Shifrin Dec 6 '12 at 10:54

Ubuntu 12.04 64 bit If you want to install everything into a user directory:

you can download the package "lib64g2c0_3.4.6-6ubuntu3_i386.deb" unpack it in a ~/temp folder with: "dpkg -x lib64g2c0_3.4.6-6ubuntu3_i386.deb ~/temp"

make a symbolic link of the content (or move the content if you prefer) of ~/temp/usr/lib64 to:

InstallR[] doesn't complain anymore. No need to make R an executable or change the Paths in the R script.

For Ubuntu 14.04 64 bits, the following works:

Needs["RLink"];
SetEnvironment["LD_LIBRARY_PATH" -> "/usr/lib/R/lib"]
InstallR["RHomeLocation" -> "/usr/lib/R"]


Without the SetEnvironment[] line, I got exactly the same errors as @swish.

• This answer was the solution for me – Lindon Oct 13 '14 at 13:40

On SUSE 13.1 InstallR[] worked after installing the rpm libg2c33 - The GNU Fortran Compiler Runtime Library, which provides libg2c.so.0

• on Fedora 20, it worked after installing compat-libf2c-34 – Rojo Jul 14 '14 at 16:40

For Ubuntu 15.10 64 bits, I had to modify hebaElkholy's form slightly.

Needs["RLink"];
SetEnvironment["LD_LIBRARY_PATH" -> "/usr/lib/R/lib"]
InstallR["RHomeLocation" -> "/usr/lib/R","RVersion"->3]
`

It could not determine the version automatically.

For this to work, I first downloaded and installed R. The code above did not work before I installed R, so if I understand things right, this is using "my own R distribution", which Wolfram does not officially support except on Windows.

I installed the GNU R version directly from the Ubuntu Software Center; just searched for r-base. No hand-tweaking involved, did not move anything, just installed from the GUI (clicked install and entered my admin password).

I did check that the installation created the directory /usr/lib/R/lib, and that the installation indeed works and that it was version 3 (3.2.2). For this just typed 'R' in a terminal, then 'q()' to quit.