Skip to content
This repository was archived by the owner on Nov 21, 2020. It is now read-only.

compatible with R version 3.4.4 (2018-03-15)? #42

Open
marco86to opened this issue Aug 2, 2018 · 2 comments
Open

compatible with R version 3.4.4 (2018-03-15)? #42

marco86to opened this issue Aug 2, 2018 · 2 comments

Comments

@marco86to
Copy link

Hello, thanks for you nice and useful work!

I have installed R version 3.4.4 (2018-03-15) on Ubuntu 16.04.5 LTS. I have installed your class trough composer and upgrade it to the dev-master version.

I then run a basic php script:
`ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require 'vendor/autoload.php';

use Kachkaev\PHPR\RCore;
use Kachkaev\PHPR\Engine\CommandLineREngine;

$args = array();
$args['pathToErrorFile'] = '/home/marco/logs/errors.txt';

$prog = new CommandLineREngine('/usr/bin/R', $args);
$r = new RCore($prog);

echo $r->run('exp(1)');`

but the page enter in a infinite loop when I try to make the run function. no log file is created.

I have also tried to run the following code with the same result:
$rProcess = $r->createInteractiveProcess(); $rProcess->start(); $rProcess->write('x = 100'); $rProcess->write('x * x'); echo $rProcess->getAllResult();

if I run R as apache (sudo -u www-data /usr/bin/R) I am able to run correctly all the comands on R

thank-you
Marco

@kachkaev
Copy link
Owner

kachkaev commented Aug 2, 2018

Hi @marco86to, sorry to hear this! I believe that the issue is to do with I/O between PHP and R and unfortunately I don't know how to fix it. A similar problem was reported recently by @dipenpatel235 in #41.

Could you please help me with investigating? I'll be happy to accept a PR with the fix!

@marco86to
Copy link
Author

Hi @kachkaev, thanks for your fast reply. I have done some tests and just comment the following while circle on https://github.com/kachkaev/php-r/blob/master/src/Kachkaev/PHPR/Process/CommandLineRProcess.php:

// Skip the startup message (if any) do { $out = fread($this->pipes[1], $this->infiniteLength); usleep($this->sleepTimeBetweenReads); } while ($out !== '> ' && substr($out, -3) !== "\n> ");

if I comment that everything is working well
thanks
Marco

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants