public function startPlot() { $f = CodeUtils::createTempFile("RcallerPlot"); //addRCode("png(\"" + f.toString().replace("\\", "/") + "\")"); /* * File path seperator may be buggy in Windows. Look here again */ $this->addRCode("png(\"" . $f . "\")"); return $f; }
public function runAndReturnResult($var) { $commandline = null; $result = null; $rSourceFile = null; $outputFile = null; if ($this->RscriptExecutable == null) { throw new Exception("RscriptExecutable is not defined. Please set this variable to full path of Rscript executable binary file."); } $outputFile = CodeUtils::createTempFile("RCallerPhpOutput"); $this->rcode->addRCode("cat(makexml(obj=" . $var . ", name=\"" . $var . "\"), file=\"" . $outputFile . "\")\n"); $rSourceFile = $this->createRSourceFile(); try { $commandline = $this->RscriptExecutable . " " . $rSourceFile; //this Process object is local to this method. Do not use the public one. $process = exec($commandline); } catch (Exception $e) { throw new Exception("Can not run " . $this->RscriptExecutable . ". Reason: " + $e); } $this->parser->setXMLFile($outputFile); try { $this->parser->parse(); } catch (Exception $e) { print $this->rcode->toString(); throw new Exception("Can not handle R results due to : " . $e); } }