Introduction to Calling R Functions

R is a freely available language and environment for statistical computing and graphics. Like IMLPlus, the R language has features suitable for developers of statistical algorithms: the ability to manipulate matrices and vectors, a large number of built-in functions for computing statistical quantities and for creating statistical graphs, and the capability to extend the basic function library by writing user-defined functions. There are also a large number of R packages that implement specialized computations.

SAS/IML Studio has an interface to the R language that enables you to submit R statements from within your IMLPlus program. In previous chapters you learned how to transfer data between SAS/IML Studio and a SAS server, how to call SAS procedures, and how to read the results back into SAS/IML Studio. This chapter describes how to transfer data to R, how to call R functions, and how to transfer the results to a number of SAS data structures.

The program statements in this chapter are distributed with SAS/IML Studio. To open the program that contains the statements:

  1. Select File Open File from the main menu.

  2. Click Go to Installation directory near the bottom of the dialog box.

  3. Navigate to the Programs\Doc\STATGuide folder.

  4. Select the file.

  5. Click Open.

In order to run the examples in this chapter, you must first install R on the same PC that runs SAS/IML Studio. For details on how to install R and which versions of R are supported, see the chapter "Accessing R" in the SAS/IML Studio online Help.