Skip to content

Flushing the R output buffer.

1 message · Richard

#
Hi David,

thats interesting, I'll keep it in mind for the future.

The solution I came up with involved using PHP to attach a script string
to the end of the command line that starts up R like:

$R_script = "R --silent --slave 2>&1 << 'END'" . $R_script;
$R_script .= "quit()\n";
$R_script .= "END\n";
$file_pointer = popen($R_script. "r");
$R_script_result = "";
while(!feop($file_pointer))
{
    $R_script_result .= fread($file_pointer, 1024);
}
pclose($file_pointer);
The script string was then massaged to extract the values I needed.
In my case I used R to format a string that was a PHP script,
extracted this from $R_script_result  and performed a PHP eval on it
so I did not have to do any complex parsing stuff.

Hopes this helps you some time.

Regards from Richard
"David B. Dahl" wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._