bricas / statistics-r

Controls the R (R-project) interpreter through Perl

Home Page:http://metacpan.org/release/Statistics-R/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trailing newline causes R Error

seales opened this issue · comments

The below commands should be equivalent, but the latter causes an error. Seems like this is because wrap_cmd adds on a semicolon without checking to see if an actual command proceeds it:

$cmd .= qq`; write("`.EOS.qq`",stdout())\n`;
. Otherwise, very useful module 👍.

use Statistics::R;

my $R = Statistics::R->new();

$R->run(qq{
   a = 1;
   b = 2;});  # no error

$R->run(qq{
   a = 1;
   b = 2;\n\n});   # error because of newline

The output is

Problem while running this R command:

     a = 1;
     b = 2;


Error:
unexpected ';' in "  ;"
Execution halted