English
=head1 NAME
Rcmd - Perl interface for R language
=head1 SYNOPSIS
use Rcmd;
$rcmd = new Rcmd;
@result = $rcmd->exec("<R commands>","<next R command>");
=head1 DESCRIPTION
Rcmd enables Perl manipulation of the R language, simply executing them
through $rcmd->exec() function. Input is an array of R commands.
ex:
print $rcmd->exec(
"x_5",
"y_4",
"z_x*y",
"z"
);
Returned values are always an array. Therefore, in case the returned value
is only one, the value is accessible as:
@val = $rcmd->exec("y");
print $val[0];
All the values are saved in each session. Thus,
$val1 = $rcmd->exec( "x_5" , "x" );
$val2 = $rcmd->exec( "x");
will output "5" for both $val1 and $val2.
Obviously, it is also possible to use perl variables, as:
$i = 3;
print $rcmd->exec("y_y*$i","x");
The strength of R graphing abilities can be accessed as:
@array = $rcmd->exec(
"postscript(\"/tmp/out.ps\")",
"x_c(1:10)",
"y_c(3,6,3,5,8,0,1,9,2,6)",
"plot(x,y)",
"z_lsfit(x,y)",
"abline(z)",
"y"
);
system("gs /tmp/out.ps");
#R language is S-plus clone availabe with GPL at http://www.r-project.org/