NAME
Statistics::R::IO::Rserve - Supply object methods for Rserve communication
VERSION
version 0.071
SYNOPSIS
use Statistics::R::IO::Rserve;
my $rserve = Statistics::R::IO::RDS->new('someserver');
my $var = $rserve->eval('1+1');
print $var->to_pl;
$rserve->close;
DESCRIPTION
Statistics::R::IO::Rserve
provides an object-oriented interface to communicate with the Rserve binary R server.
This allows Perl programs to access all facilities of R without the need to have a local install of R or link to an R library.
METHODS
CONSTRUCTOR
- new $server
-
The single-argument constructor can be invoked with a scalar containing the host name of the Rserve server. The method will immediately open a connection to the server using IO::Socket::INET and perform the initial steps prescribed by the protocol. The method will raise an exception if the connection cannot be established or if the remote host does not appear to run the correct version of Rserve.
- new $handle
-
The single-argument constructor can be invoked with an instance of IO::Handle containing the connection to the Rserve server, which becomes the 'fh' attribute. The caller is responsible for ensuring that the connection is established and ready for submitting client requests.
- new ATTRIBUTE_HASH_OR_HASH_REF
-
The constructor's arguments can also be given as a hash or hash reference, specifying values of the object attributes. The caller passing the handle is responsible for ensuring that the connection is established and ready for submitting client requests.
- new
-
The no-argument constructor uses the default server name 'localhost' and port 6311 and immediately opens a connection to the server using IO::Socket::INET, performing the initial steps prescribed by the protocol. The method will raise an exception if the connection cannot be established or if the remote host does not appear to run the correct version of Rserve.
ACCESSORS
- server
-
Name of the Rserve server.
- port
-
Port of the Rserve server.
- fh
-
A connection handle (stored as a reference to the IO::Handle) to the Rserve server.
METHODS
- eval EXPR
-
Evaluates an R expression, given as text string in REXPR, on an Rserve server and returns its result as a Statistics::R::REXP object.
- ser_eval EXPR
-
Evaluates an R expression, given as text string in REXPR, on an Rserve server and returns its result as a Statistics::R::REXP object. This method uses the CMD_serEval Rserve command (code 0xf5), which is designated as "internal/special" and "should not be used by clients". Consequently, it is not recommended to use this method in a production environment, but only to help debug cases where
eval
isn't working as desired. - close
-
Closes the object's filehandle. This method is automatically invoked when the object is destroyed if the connection was opened by the constructor, but not if it was passed in as a pre-opened handle.
BUGS AND LIMITATIONS
Instances of this class are intended to be immutable. Please do not try to change their value or attributes.
There are no known bugs in this module. Please see Statistics::R::IO for bug reporting.
SUPPORT
See Statistics::R::IO for support and contact information.
AUTHOR
Davor Cubranic <cubranic@stat.ubc.ca>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by University of British Columbia.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007