php-r
php-r copied to clipboard
Test run returns > options(error=expression(NULL)) on Ubuntu
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
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.
Same problem here. @ukebako did you eventually solve the issue?
Actually adding \n at the end of expression was enough for me. I just grab what I need from the output.
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.
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");
ohkay . how to make it work on fedora 24 too?