When I install RLink:


then evaluate the command


I see that it is running

{"R version 2.14.0 (2011-10-31)"}

a version which I did not intentionally install on my system. I believe that Mathematica downloaded this itself. Now I wish to install packages. For example:



General error in function RLink`Private`withRTemporaryVariables >>

Is it possible to install packages with Mathematica's version of R? Even a command line solution would be great.


It seems that the error above was an aberration. It stopped showing up after I restarted Mathematica. Following Sasha's advice, I tried to add a repository:

REvaluate["install.packages('LaplacesDemon', repos='http://cran.wustl.edu/')"]

and the error is equally as bad:

REvaluate::rerr: Failed to retrieve the value for variable or piece of code
install.packages('LaplacesDemon', repos='http://cran.wustl.edu/'. 
The following R error was encountered: Error in typeof(myRandomVar123456759046) :
object 'myRandomVar123456759046' not found >>

Similar errors for ggplot2, Zelig, etc. There appears to be a whole R tree in


but the R version there doesn't seem to be usable.

  • $\begingroup$ What platform are you using? Running the last REvaluate command bring a repository selection dialog for me on Windows. $\endgroup$
    – Sasha
    Commented Nov 29, 2012 at 1:21
  • $\begingroup$ You might want to run REvaluate[".Library"] to find out the location of R-installation and then run it from a command line. $\endgroup$
    – Sasha
    Commented Nov 29, 2012 at 1:25
  • $\begingroup$ It looks like it's possible to wget a binary package from a CRAN mirror right into the .../library directory. Now, I'm trying to figure out how to work with REvaluate itself. $\endgroup$
    – Eric Brown
    Commented Nov 29, 2012 at 2:08
  • $\begingroup$ @Jens same thing here. $\endgroup$
    – rcollyer
    Commented Nov 29, 2012 at 2:31
  • $\begingroup$ I'm running Windows 7 64-bit and this works just fine. Perhaps a it is platform dependent or some limitation in a trial version of M? $\endgroup$
    – Andy Ross
    Commented Nov 29, 2012 at 2:43

1 Answer 1


Unfortunately package installation for RLink works currently on Windows only. Also, for Windows, you have an option of using your own version of R. While fixing package installation for other platforms may be harder, I hope we will have the functionality of using own version of R with RLink to work on other platforms reasonably soon. That would of course solve the package installation problem too, if not for the default R installation that comes with RLink.

A word of caution for users of Linux and Mac OS X: for these platforms, the default R installation used with RLink has been "processed" in a certain way (dynamic libraries, main ones and those present in the packages, were "patched" on the object code level to be able to find each other without setting any environmental variables globally). As as result of that, just adding libraries or packages to the default R installation location will generally not be enough to make sure that the package being installed works correctly with RLink. So, I would discourage people from doing that. As I said, hopefully RLink will get an option to work with own R installation working on other platforms soon enough (this is my personal hope).

  • 2
    $\begingroup$ I will update this answer when I have more to say. $\endgroup$ Commented Nov 29, 2012 at 9:24
  • $\begingroup$ Your work is appreciated. Before 9, I was writing a lot of boilerplate code to write the R input to a text file, run R, "serialize," then bring in the results. I'm starting to get it figured out, and it is very powerful. Now it looks like things are standardized and so I can write toward that. $\endgroup$
    – Eric Brown
    Commented Nov 29, 2012 at 13:39
  • 1
    $\begingroup$ @EricBrown Thanks. As I said, the issue you raised will be dealt with, I hope quite soon. I will also appreciate any other feedback on RLink you may have as you work with it. $\endgroup$ Commented Nov 29, 2012 at 15:35
  • $\begingroup$ @LeonidShifrin -- Has package installation for Mac been fixed yet? If so, could you update this response. If not, might it be fixed by the next version of Mathematica? $\endgroup$ Commented Feb 10, 2014 at 15:57
  • 1
    $\begingroup$ @s0rce I can't test on Windows right now, and package installation from within RLink only works on Windows, so I can't test this. But I've done that on Windows many times (with other librraies), and it worked all right. As far as I remeber, you have to load the library before you use it, using library(package). This may be the reason. $\endgroup$ Commented Jan 6, 2016 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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