Import library
I'm in need import libraries in my R code, but is giving the following error.
$rOutputParser = new ROutputParser();
$rProcess = $r->createInteractiveProcess();
$rProcess->start();
$resultado = "a";
$rProcess->write(<<<EOF
require("sm",lib.loc="/Library/Frameworks/R.framework/Resources/library/")
EOF
);
var_dump($rProcess->getErrors());
Result:
array (1) {
[0] =>
object (Kachkaev \ PHPR \ RError) # 77 (4) {
["inputLineNumber": "Kachkaev \ PHPR \ RError": private] =>
int (0)
["commandNumber": "Kachkaev \ PHPR \ RError": private] =>
int (0)
["command", "Kachkaev \ PHPR \ RError": private] =>
string (90) "require (" sm "lib.loc =" / Library / Frameworks / R.framework / Resources / library / ")"
["errorMessage": "Kachkaev \ PHPR \ RError": private] =>
string (97) "Loading required package: sm
Package 'sm', version 2.2-5.4: type help (sm) is summary information "
}
}
Hi @marciovsena,
By default R outputs some messages into error output not to mix them with results of calculations etc. Here is what you can normally see in RStudio:
Red text is what you’d get in $rProcess->getErrors() if you used PHP-R. I’d recommend you to simply ignore these errors – they should not negatively influence any of your further commands. Also have a look at method getLastWriteErrors() – it might be reasonable to use it instead of getErrors() if you are interested only in recently occurred errors.
I’ll leave this issue open for now; maybe someone can recommend a good solution for differentiating between info messages and real errors in error output (I personally can’t see a universal one).
Hi @marciovsena , did you use this pacage in windows now?How to do it?
Hi @kbvstmd, I am using MAC OS
