On 4/2/2012 8:20 AM, Jos? Ram?n Blas Pastor wrote:> Hi,
>
> a very simple doubt, but I do not know how to manage this.
>
> I want to plot a histogram for all data in 'datos.txt'.
> b) How could I invoke R inside Perl to do the same??
> #!/usr/bin/perl
> open(DAT,"datos.txt");
> while (<DAT>) {
> chomp;
> push(@datos,$_);
> }
> #now I want a histogram of values in @datos
You can use Statistics::R for that, for example:
use Statistics::R;
my $R = Statistics::R->new();
$R->set( 'data', \@datos );
$R->run( q`d<-hist(data)` );
$R->run( qq`png("histogram.png")` );
$R->run( qq`plot(d, main="Histogram")` );
$R->run( q`dev.off()` );
Cheers,
Till