Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

Commented Unassigned: Can't access R package libraries [127]

$
0
0
This Project looks very promising, please dont abandon it in any case.
I am having, like many before me, issues with accessing R packages from within an REngine. My specs:

.) Win XP SP3
.) Visual Studio Express C# 2010
.) WinForms Project
.) R.NET 1.5.10
.) R-3.0.3 (although there are some other dlls lying around in other directories from previous R installations)
.) operating in an office network, no admin. R is installed locally.

As you can see in the code, I am manually setting R_HOME. Without that, it doesnt work at all. I am trying to set the libs path as well, but it just tells me that there are no library trees in lib.loc. When i output the .libsPath() I get a strange result: the DVD drive D:/. However when I ask the same question in the R console, it tells me the correct path. Any help dearly appreciated.
Of course I tried crosschecking with existing issues/discussions but to no avail.

```
string rhome = @"C:\Programme\R\R-3.0.3";
System.Environment.SetEnvironmentVariable("R_HOME", rhome);
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome + @"\bin");
System.Environment.SetEnvironmentVariable("R_LIBS", @"\library");

REngine engine = REngine.GetInstance();
engine.Initialize();
engine.Evaluate("library(timeSeries)");
engine.Dispose();
```
Comments: There are a few incorrect settings, but R.NET should still have worked with this sequence of statements. * I take note that with a non-admin installation, the discovery of R_HOME may not work indeed; however your setting R_HOME as an env var looks fine to overcome that. * Appending the path: ``` rhome + @"\bin" ``` to PATH is incorrect; I believe R 3.0 and above now always has binaries in architecture subfolders. The call to GetInstance seems to discover the right location of R.dll anyway, otherwise you could not even call .libPaths(). * As an aside, I recommend you use following the syntax rather than setting env vars directly. ``` REngine.SetEnvironmentVariables(rPath: Path.Combine(rhome, "bin", "i386"), rHome: rhome); REngine engine = REngine.GetInstance(); engine.Evaluate("library(timeSeries)"); ``` * The use of R_LIBS looks incorrect; you should not need to set R_LIBS unless you really have additional libraries location besides the usual R one. The argument you provide is also a not an absolute path. This may be what prevents .libPaths() from returning the correct value(s). ``` System.Environment.SetEnvironmentVariable("R_LIBS", @"\library"); ```

Viewing all articles
Browse latest Browse all 1634

Trending Articles