UCS::R - UCS/Perl interface to R
use UCS::R;
UCS::R::Start(); # start R backend explicitly
UCS::R::Stop(); # terminate R backend (if possible)
@x = UCS::R::Exec($cmd); # execute R cmd (must return numeric vector)
UCS::R::LoadVector("my.x", \@data); # load numeric vector efficiently into R
$data = UCS::R::DumpVector("my.x"); # returns arrayref
# access to special functions and statistical distributions
# through the UCS::SFunc module
The UCS::R module provides an interface to the R statistical environment and the UCS/R libraries on an R interpreter running in the background. When available (as determined by the installation script), the RSPerl interface is used for efficient communication with the R interpreter. Otherwise, the system falls back on a slower but more portable solution that simulates an interactive R session through use of the Expect module. See the UCS::R::RSPerl and UCS::R::Expect manpages for some details about the strengths and limitations of the two backends.
The UCS::R interface is mainly used by the UCS::SFunc module to make the R implementations of special functions (binomial coefficients, Gamma function, Beta function) and statistical distributions (binomial, Poisson, normal, chi-squared, hypergeometric) available to UCS/Perl, without relying on an external maths library and/or compiled C code.
;
), so that it leaves a single command prompt at the beginning of a line after execution. Avoid cat()
and any functions that prompt for user input, otherwise UCS::R::Exec will become confused and may hang.scan
function in R). The data @data are passed in as an array reference and will be stored in the R variable $varname.write()
function). The data stored in the R variable $varname (which must be a numeric vector) are returned as an anonymous array reference $data.The special functions and statistical distributions provided through the R interface are not exported by this module. Use UCS::SFunc instead. All available functions are documented in the UCS::SFunc manpage. They are available under the same names in the UCS::R package. For instance, the R implementation of the lgamma function can be accessed explicitly as UCS::R::lgamma.
Copyright 2004-2005 Stefan Evert.
This software is provided AS IS and the author makes no warranty as to its use and performance. You may use the software, redistribute and modify it under the same terms as Perl itself.