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

Import library #5

Open
omarciovsena opened this issue Jan 18, 2015 · 3 comments
Open

Import library #5

omarciovsena opened this issue Jan 18, 2015 · 3 comments

Comments

@omarciovsena
Copy link

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 "
   }
}
@kachkaev
Copy link
Owner

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:

screen shot 2015-01-20 at 12 06 10

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).

@kbvstmd
Copy link

kbvstmd commented Jan 22, 2015

Hi @marciovsena ,
did you use this pacage in windows now?How to do it?

@omarciovsena
Copy link
Author

Hi @kbvstmd,
I am using MAC OS

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

3 participants