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

______________________________________________
[email protected] 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.

Reply via email to