# Installing CRAN Packages

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 RLinkPrivatewithRTemporaryVariables >>


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


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.

-
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

@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. – Leonid Shifrin Jan 6 at 9:31