Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I install RLink:

Needs["RLink`"]
InstallR[]

then evaluate the command

REvaluate["R.version.string"]

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:

REvaluate["install.packages('LaplacesDemon')"]

yields

REvaluate::err: 
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.

EDIT:

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

$HomeDirectory/Library/Mathematica/Paclets/Repository/RLinkRuntime-MacOSX-x86-64-9.0.0.0/SystemFiles/MacOSX-x86-64/R/library

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

share|improve this question
    
What platform are you using? Running the last REvaluate command bring a repository selection dialog for me on Windows. –  Sasha Nov 29 '12 at 1:21
    
You might want to run REvaluate[".Library"] to find out the location of R-installation and then run it from a command line. –  Sasha Nov 29 '12 at 1:25
    
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. –  Eric Brown Nov 29 '12 at 2:08
    
@Jens same thing here. –  rcollyer Nov 29 '12 at 2:31
    
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? –  Andy Ross Nov 29 '12 at 2:43
add comment

1 Answer

up vote 7 down vote accepted

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).

share|improve this answer
2  
I will update this answer when I have more to say. –  Leonid Shifrin Nov 29 '12 at 9:24
    
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. –  Eric Brown Nov 29 '12 at 13:39
1  
@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. –  Leonid Shifrin Nov 29 '12 at 15:35
    
@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? –  Seth Chandler Feb 10 at 15:57
    
@SethChandler Unfortunately, this has not been resolved yet. And, while I'd very much like to get this done for V10.0, right now I absolutely have zero time for this. However, did you try these instructions? It works on at least some Mac machines. And once you connect to a custom R distro (if that works for you), you can install any package you want, e.g. from within that R distro command line prompt (not sure whether package installation on Mac will work via RLink). –  Leonid Shifrin Feb 10 at 21:12
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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