snape has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am interested in calling R script from perl. I am doing it because R takes a huge amount of time in reading the file and I have 500 output files (700 kbs each). I need to do matrix operations on it (thats why I am using R as its very fast in doing the same as it contains many functions :)) on unix platform. I am getting the output file from the perl script. I need to extend the script by calling the R script and passing array (which contains the contents of the file ) as the argument. Can you please help me with the same ?

Glimpse of my code

my $filename = 'file1.txt'; open my $posFile, $filename or die $!; open my $OUTFILE, '>', 'file2.txt'; @scoreIndividuals = &score( \*$file1,\*$file2); close($posFile); close($OUTFILE); #### Need to pass the contents of the file (as an array) to #### R script which does only operation on the contents #### (and R sc +ript does not read the file) exit; sub score{ ### Calculates score and writes on the file. }

Replies are listed 'Best First'.
Re: Calling R script from Perl
by marto (Cardinal) on Mar 25, 2010 at 20:40 UTC

    Statistics::R maybe? There seems to be a few modules on CPAN which may be of interest.

Re: Calling R script from Perl
by GrandFather (Saint) on Mar 26, 2010 at 00:26 UTC

    Maybe you could use PDL instead of using R?


    True laziness is hard work