« View all new features in Mathematica 9  previous  |  next 
New in Mathematica 9Built-in Integration with R

Using Higher-Order Functions and Closures to Structure Code: Flexible Plotting Routines  

This example illustrates some means of code composition supported by RLink, which allow smooth and productive combined R-Mathematica workflows.
Load RLink.
In[1]:=
Click for copyable input
X

The following creates a generic R wrapper that creates the plot and saves it to a file, and defines certain parameters for the resulting image.

In[2]:=
Click for copyable input
X
Out[2]=

Create a Mathematica counterpart wrapper that automates file import and adds error-checking.

In[3]:=
Click for copyable input
X

Display the result.

In[4]:=
Click for copyable input
X
Out[4]=