How do I InstallR on OS X to use my already installed and configured R?
Simply using
InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources"]
results in
$Failed
InstallR::nopaclet: Could not find RLink runtime installed. Please use RLinkResourcesInstall to install it
How do I connect Mathematica to my installed R? Do I have to install a separate R for Mathematica?
Answer
Try like this in a fresh kernel:
Needs["RLink`"]
SetEnvironment["DYLD_LIBRARY_PATH" -> "/Library/Frameworks/R.framework/Resources/lib"];
InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources"];
Update: With Mathematica 10.0.1 (but not 10.0.0), use
InstallR["RHomeLocation" -> "/Library/Frameworks/R.framework/Resources", "RVersion" -> 3]; (* for M 10.0.1 *)
This works if you are using the R distribution from http://www.r-project.org/, but if I recall correctly some people said it didn't work with some other R distributions (e.g. MacPorts's R). I only tried with the official R.
To check that you are indeed running with the chosen version of R, evaluate
REvaluate["R.version.string"]
which on my system returns {"R version 3.0.3 (2014-03-06)"} (as I have R 3.0.3).
I described this before here.
Note: With Mathematica 9.0.1 it is necessary to first make sure that RLink is set up and working with Mathematica's internal R distribution, as described in the user guide. Once that is done, an external R can be used as above. Otherwise InstallR might exit with an InstallR::nopaclet error.
Comments
Post a Comment