Re: [R] Generating R plots through Perl - Solution

2007-03-06 Thread Ryan.G.Huckstorf
Hello,

I tried what you suggested (i.e. combine the separate plot creation
commands into one command from Perl to R), and it worked.  The syntax is
as follows:

$R-send(qq (xVal - c(1,2,3,4,5,6)));
$R-send(qq (yVal - c(3,5,2,6,1,5)));
$R-send(qq (c(pdf(C:/Test Environment/R/perlPlotTest.pdf), plot(xVal,
yVal), dev.off(;

I appreciate your help with this, and I will look into ruby and the r
for ruby project for future use.

Thanks again,
Ryan


-Original Message-
From: Charilaos Skiadas [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 01, 2007 6:15 PM
To: Huckstorf, Ryan
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Generating R plots through Perl

On Mar 1, 2007, at 6:28 PM, [EMAIL PROTECTED] wrote:

First off, if you are working in perl you might want to be aware of ruby
and the r for ruby project:
http://rubyforge.org/projects/r4ruby/

 Hello,

 $R-send(qq (xVal - c(1,2,3,4,5,6))); $R-send(qq (yVal - 
 c(3,5,2,6,1,5))); $R-send(qq (pdf(C:/Test 
 Environment/R/perlPlotTest.pdf)));
 $R-send(qq (plot(xVal, yVal)));
 $R-send(qq (graphics.off()));

I don't really know how to write this in perl, but could you perhaps put
the last three lines all in one call to $R-send, using dev.off
() then? Don't know if it would make a difference, but that's the only
thing I could think of. I'm guessing something like this:

$R-send(qq (pdf(C:/Test Environment/R/perlPlotTest.pdf); plot (xVal,
yVal); dev.off()));

 As the code indicates, I am using R's pdf function to create a pdf 
 file containing the plot of xVal and yVal.  I am using the 
 graphics.off() function rather than the dev.off() function as I get an

 error message of simpleError in dev.off(): cannot shut down device 1

 (the null device) when dev.off() is used.  Is there another way to 
 generate and save a plot using the bridge connection that I described?

 If not, what would be an efficient way of generating and saving plots 
 from within my Perl program?  Any help would be greatly appreciated.

 Thank you,
 Ryan

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Generating R plots through Perl

2007-03-01 Thread Ryan.G.Huckstorf
Hello,

I am in the process of writing a Perl program to carry out and analyze
large numbers of regressions using R as the regression engine, and I am
using Statistics::R to create the communication bridge between the two
programs.  Statistics::R creates a pipe between R and Perl and uses
Rterm.exe (hidden during run-time) to carry out the R commands.  This
communication bridge works well for creating regression objects in R and
analyzing some of the regression results.  However, I have not been able
to create a plot using this method.  The plot commands that are executed
in R through Perl (see below) produce a pdf file with no data (i.e. the
plot data is not getting passed to the file).  It seems that the pipe
connection created via Statistics::R cannot produce a graphics device
window to save.  A very simple version of the commands that I am using
in my Perl program are as follows:

$R-send(qq (xVal - c(1,2,3,4,5,6)));
$R-send(qq (yVal - c(3,5,2,6,1,5)));  
$R-send(qq (pdf(C:/Test Environment/R/perlPlotTest.pdf)));
$R-send(qq (plot(xVal, yVal)));
$R-send(qq (graphics.off()));

As the code indicates, I am using R's pdf function to create a pdf file
containing the plot of xVal and yVal.  I am using the graphics.off()
function rather than the dev.off() function as I get an error message of
simpleError in dev.off(): cannot shut down device 1 (the null
device) when dev.off() is used.  Is there another way to generate and
save a plot using the bridge connection that I described?  If not, what
would be an efficient way of generating and saving plots from within my
Perl program?  Any help would be greatly appreciated.

Thank you,
Ryan



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.