Skip Menu |

This queue is for tickets about the Statistics-R CPAN distribution.

Report information
The Basics
Id: 62776
Status: resolved
Priority: 0/
Queue: Statistics-R

People
Owner: Nobody in particular
Requestors: DJIBEL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.06
Fixed in: (no value)



Subject: [Patchs] for Statistics::R-0.06 - fixed bugs is_started and others
Dear, Thank you for the update of this module. I am used it every time I need to use R in perl since several years. The module code is now very simple and easily to maintained, good job. I suggest you a patch to resolv some bugs in Windows and Linux platforms, an pod documentation. That is an example script : #!/usr/bin/perl use warnings; use strict; use Carp; use Statistics::R ; my $R = Statistics::R->new() ; $R->startR ; $R->send(q`postscript("file.ps" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`) ; $R->send(q`plot(c(1, 5, 10), type = "l")`) ; $R->send(q`dev.off()`); # You have forgotten this code in synopsis $R->send(qq`x = 123 \n print(x)`) ; my $ret = $R->read ; print "\$ret : $ret\n"; if ( $R->is_started ) { print "R is started\n"; } else { print "R not started\n"; } $R->stopR() ; Results : Use of uninitialized value in -s at C:/Perl/site/lib/Statistics/R/Bridge.pm line 727. $ret : [1] 123 Can't locate object method "is_started" via package "win32" (perhaps you forgot to load "win32"?) at C:/Perl/site/lib/Statistics/R.pm line 86. I have join you two patchs for R.pm and Bridge.pm Best regards, Djibril (DJIBEL)
Subject: patch_for_R.txt
--- C:/Users/beline/Desktop/patchRSTAT/ancien/R.pm Sat Nov 6 12:32:53 2010 +++ C:/Users/beline/Desktop/patchRSTAT/R.pm Sat Nov 6 12:30:04 2010 @@ -5,7 +5,7 @@ use Statistics::R::Bridge; -our $VERSION = '0.06'; +our $VERSION = '0.07'; my( $this, @ERROR ); @@ -83,7 +83,7 @@ sub is_started { my $this = shift; - $this->{ BRIDGE }->{ OS }->is_started; + $this->{ BRIDGE }->is_started; } sub send { @@ -122,12 +122,14 @@ $R->startR ; - $R->send(q`postscript("file.ps" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`) ; + $R->send(q`postscript("C:/file.ps" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`) ; $R->send(q`plot(c(1, 5, 10), type = "l")`) ; - + $R->send(q`dev.off()`); + $R->send(qq`x = 123 \n print(x)`) ; my $ret = $R->read ; - + print "\$ret : $ret\n"; + $R->stopR() ; =head1 NEW
Subject: patch_for_Bridge.txt
--- C:/Users/beline/Desktop/patchRSTAT/ancien/Bridge.pm Sat Nov 6 12:32:53 2010 +++ C:/Users/beline/Desktop/patchRSTAT/Bridge.pm Sat Nov 6 12:43:54 2010 @@ -5,7 +5,7 @@ use IO::Select; -our $VERSION = '0.06'; +our $VERSION = '0.07'; our $HOLD_PIPE_X; my $this; @@ -660,7 +660,7 @@ $this->{ R_DIR } = $args{ r_dir } || $args{ R_dir } || ''; $this->{ TMP_DIR } = $args{ tmp_dir } || ''; - if ( !-s $this->{ R_BIN } ) { + if ( not defined $this->{ R_BIN } or !-s $this->{ R_BIN } ) { my @files = qw(R R-project Rproject); ## my @path = (split(":" , $ENV{PATH} || $ENV{Path} || $ENV{path} ) , '/usr/lib/R/bin' , '/usr/lib/R/bin' ) ; # CHANGE MADE BY CTBROWN 2008-06-16 @@ -697,7 +697,7 @@ } } - if ( !-s $this->{ R_BIN } ) { + if ( not defined $this->{ R_BIN } or !-s $this->{ R_BIN } ) { $this->error( "Can'find R binary!" ); return undef; } @@ -724,7 +724,7 @@ $this->{ R_DIR } = $args{ r_dir } || $args{ R_dir }; $this->{ TMP_DIR } = $args{ tmp_dir }; - if ( !-s $this->{ R_BIN } ) { + if ( not defined $this->{ R_BIN } or !-s $this->{ R_BIN } ) { my $ver_dir = ( $this->cat_dir( "$ENV{ProgramFiles}/R" ) )[ 0 ]; my $bin = "$ver_dir/bin/Rterm.exe"; @@ -764,7 +764,7 @@ } } - if ( !-s $this->{ R_BIN } ) { + if ( not defined $this->{ R_BIN } or !-s $this->{ R_BIN } ) { $this->error( "Can'find R binary!" ); return undef; }
Thanks for all of this work. I've applied a variation of your patches. The differences are as follows: * I did not add C:/ to the postscript line in the SYNOPSIS, as this is win32 specific * The initial part of your Bridge.pm patch shouldn't be necessary as $this->{ R_BIN } is set to the empty string by default, rather than undef * I've applied the same default to the Win32() section, which should eliminate the undef problem you're seeing. Please try version 0.07 (on its way to CPAN now). Should any problem persist, either re-open this bug or file a new one. Thanks again for this report. Cheers.