NAME Statistics::R - Controls the R (R-project) interpreter through Perl. DESCRIPTION This will permit the control of the the R (R-project) interpreter through Perl in different architectures and OS. You can for example, start only one instance of the R interpreter and have different Perl process accessing it. SYNOPSIS use Statistics::R; my $R = Statistics::R->new(); $R->startR; $R->send(q`postscript("" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`); $R->send(q`plot(c(1, 5, 10), type = "l")`); $R->send(q``); $R->send(qq`x = 123 \n print(x)`); my $ret = $R->read; print "\$ret : $ret\n"; $R->stopR(); NEW When creating the R bridje object (Statistics::R), you can set some options: log_dir The directory where the bridge between R and Perl will be created. R and Perl need to have read and write access to the directory! *By dafault it will be created at *%TMP_DIR%/Statistics-R*.* r_bin The path to the R binary. *By default the path will be searched in the default installation path of R in the OS.* r_dir The directory of R. tmp_dir A temporary directory. *By default the temporary directory of the OS will be used/searched.* METHODS startR Start R and the communication bridge. start_sharedR Start R or use an already running communication bridge. stopR Stop R and the bridge. restartR stop() and start() R. Rbin Return the path to the R binary (executable). send ($CMD) Send some command to be executed inside R. Note that *$CMD* will be loaded by R with *source()* read ($TIMEOUT) Read the output of R for the last group of commands sent to R by *send()*. lock Lock the bridge for your PID. unlock Unlock the bridge if your PID have locked it. is_blocked Return *TRUE* if the bridge is blocked for your PID. In other words, returns *TRUE* if other process has *lock()ed* the bridge. is_started Return *TRUE* if the R interpreter is started, or still started. clean_up Clean up the enverioment, removing all the objects. error Return the last error message. INSTALL To install this package you need to install R in your OS first, since *Statistics::R* need to find R path to work fine. A standart installation of R on Win32 and Linux will work fine and detected automatically by *Statistics::R*. Download page of R: Or go to the R web site: EXECUTION FOR MULTIPLE PROCESS The main pourpose of *Statistics::R* is to start a single R interpreter that hear multiple Perl process. Note that to do that R and Perl need to be running with the same user/group level. To start the *Statistics::R* bridge you can use the script **: $> start From your script you need to use the *start_sharedR()* option: use Statistics::R; my $R = Statistics::R->new(); $R->start_sharedR; $R->send('x = 123'); exit; Note that in the example above the method *stopR()* wasn't called, sine it will close the bridge. SEE ALSO * Statistics::R::Bridge * The R-project web site: * Statistics:: modules for Perl: AUTHOR Graciliano M. P. MAINTAINER Brian Cassidy COPYRIGHT & LICENSE This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.