- BUGS AND LIMITATIONS
- COPYRIGHT AND LICENSE
Statistics::R::IO::Rserve - Supply object methods for Rserve communication
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;
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.
- 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.
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.
Name of the Rserve server.
Port of the Rserve server.
A connection handle (stored as a reference to the IO::Handle) to the Rserve server.
- eval EXPR
- 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
evalisn't working as desired.
- get_file REMOTE_NAME [, LOCAL_NAME]
Transfers a file named REMOTE_NAME from the Rserve server to the local machine, copying it to LOCAL_NAME if it is specified. The file is transferred in binary mode. Returns the contents of the file as a scalar.
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.
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.
See Statistics::R::IO for support and contact information.
Davor Cubranic <email@example.com>
This software is Copyright (c) 2017 by University of British Columbia.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007