[R] Mathematica and R
Marc Schwartz
marc_schwartz at me.com
Wed Jul 14 16:24:11 CEST 2010
On Jul 14, 2010, at 6:59 AM, David Bickel wrote:
> What are some effective ways to leverage the strengths of R and Mathematica for the analysis of a single data set?
>
> More specifically, are there any functions that can assist with any of the following?
> 1. Calling an R function from Mathematica.
> 2. Calling a Mathematica function from R.
> 3. Using XML or another reliable data format to pass vectors, matrices, and/or lists from one environment to the other.
>
> Any advice would be appreciated.
>
> David
See:
http://www.scienceops.com/Rlink2.asp
http://library.wolfram.com/infocenter/Conferences/6510/
Those provide hints on calling R from Mathematica using a commercial application (Windows Vista only apparently).
It would seem, logically, that the commercial world (SAS, SPSS, etc.) has deemed it more important to provide R functionality from within their applications, than vice versa.
If Mathematica can be run in a batch mode using a CLI interface, it may be possible to call Mathematica from within R using the system() function. However, parsing the results of the Mathematica operation in R will be up to you.
Similarly, if Mathematica has the ability to call external batch files, you could run R code in that fashion, again, having to deal with parsing the results in Mathematica.
In so far as moving data back and forth, you can review the R Data Import/Export manual:
http://cran.r-project.org/doc/manuals/R-data.html
to identify common formats (eg. CSV files) that can be used by both applications. I don't use Mathematica, so am unfamiliar with their, presumably proprietary, formats.
HTH,
Marc Schwartz
More information about the R-help
mailing list