The R/Splus--Perl Interface

02 August 2007

RSPerl_0.92-1.tar.gz

Overview

This package provides a bidirectional interface for calling R from Perl and Perl from R. This embeds one interpreter (e.g. R) within the process of the other interpreter (e.g. Perl). One can call routines and functions in the other language as if they were part of the local environment. This avoids having to program in a different language while making the functionality in the other system transparently available with no additional coding. Values computed in one call are available to future calls. This makes Perl more interactive, also allows the R/Splus programmer to use convenient and familiar syntax to mix computations in the two different sytems, and provide statistical functionality to Perl applications..

One of the main benefits of this package is that it avoids the cost of spawning perl processes for simple things and allows commands to be cumulated over a session rather than specified ahead-of-time in a Perl script. Additionally, it provides accesss to many Perl modules and tools whose counterparts do not exist in R/SPlus. See CPAN

Download

The source RSPerl_0.92-1.tar.gz.

Installation

R

 R CMD INSTALL -c -l <wherever> RSPerl_0.92-1.tar.gz
By default, it will do some manipulation to link in C code for the installed Perl modules that use C code. This can be controlled by setting the environment variable PERL_MODULES. To avoid any modules, set the environment variable PERL_MODULES to "no".

To use R from within Perl,

 R CMD INSTALL -c -l <wherever> --configure-args='--with-in-perl' RSPerl_0.92-1.tar.gz
Also, please read RFromPerl.html.

To find the Perl modules for the R interface, and to find the necessary shared libraries/DLLs, please use either of the scripts RSPerl.csh or RSPerl.bsh in the RSPerl/scripts/ directory where you installed the package. These set important environment variables.

SPlus 5 & 6

This code has been developed to run within S-Plus. This has not been extensively maintained, but should be reasonably straightforward to upgrade.

Requirements

  • You will need Perl, and (probably) version 5.005 or greater.
    I am using 5.8.1 on my Mac OSX machine.
  • A recent version of R.
  • Documentation

  • Features and partial "reference card".
  • Some simple examples, somewhat annotated.
  • A very unfinished document gives some details and the philosohpy.
  • Change log for the different releases.
  • R module in Perl
    Documentation for the Perl module R and its routines, including calling R functions, evaluating S commands, registering Perl converter routines, etc.
  • Calling R From Perl
    A (very) brief description of calling R from Perl. This only works on Unix. (Only tested on Linux.) Do not expect this to run on Windows.
    Also, take a look at example Perl scripts that call R to do some basic things.
  • auto.pl
    Illustration of calling R functions directly from Perl using the AUTOLOAD routine for undefined perl routines.
  • test.pl
    Test for many different aspects of R, including loading a library, examining the search path and object list, calling random number generators, plotting, using simple function calls, named argument calls, and expression evaluation.
  • test1.pl
    Test of basic interface to generate a plot.
  • test2.pl
    Very simple call to S function sum.
  • test3.pl
    Call to plot with named arguments.
  • test4.pl
    Test of exporting R objects as references to Perl and resolving them in subsequent calls.

  • Duncan Temple Lang <duncan@wald.ucdavis.edu>
    Last modified: Thu Jun 8 11:46:45 PDT 2006