php-r icon indicating copy to clipboard operation
php-r copied to clipboard

Test run returns > options(error=expression(NULL)) on Ubuntu

Open ukebako opened this issue 9 years ago • 6 comments

Hi. I run the following code:

$r = new RCore(new CommandLineREngine('R'));
echo $r->run("5+3");

On my Mac it works as expected, but when I run it on Ubuntu server it returns just

> options(error=expression(NULL))

UPDATE I've found out that there's something wrong with end of line. If i run something like this:

echo $r->run("5+3\n");

then it returns both 'options(...' and the result of the operation in the returning string

ukebako avatar Jun 14 '15 16:06 ukebako

Hi @ukebako,

I haven't tested the code in ubuntu, so there might be problems as you describe. Feel free to contributed to the repository by submitting a pull request if you find a robust and cross-platform solution to what you've discovered.

kachkaev avatar Jun 14 '15 22:06 kachkaev

Same problem here. @ukebako did you eventually solve the issue?

cchenship avatar Jul 30 '15 18:07 cchenship

Actually adding \n at the end of expression was enough for me. I just grab what I need from the output.

ukebako avatar Aug 01 '15 07:08 ukebako

Thanks, @ukebako , the "\n" trick did work for me except the leading "options(error=expression(NULL))". I was wondering whether you were able to remove that leading string. But, anyhow, you trick helped a lot.

cchenship avatar Aug 04 '15 15:08 cchenship

I commented out line 45 in CommandLineRProcess.php but I doubt that is the correct solution

fwrite($this->pipes[0], "options(error=expression(NULL))\n");

tallsam avatar Nov 25 '15 06:11 tallsam

ohkay . how to make it work on fedora 24 too?

irenge avatar Jul 05 '16 16:07 irenge