Package ‘stats’ in options<”defaultPackages”> was not found

May 21, 2013 at 5:35 PM
Hi,

I'm trying to use R.NET and I get this message on the output of the program (it's a c# console program):

Error in inDL<x, as.logical<local>, as.logical<now>, …> :
unable to load shared object ‘C:/Program Files/R/R-3.0.0/library/stats/libs/i386/stats.dll’:
LoadLibrary failure: The specified module could not be found.

During startup – Warning message:
Package ‘stats’ in options<”defaultPackages”> was not found


I tried to add 'stats' library by :

engine.Evaluate("C:/Program Files/R/R-3.0.0/library");
engine.Evaluate(".libPaths(\"C:/Program Files/R/R-3.0.0/library\")");

but it didn't have any effect.

Currently I can successfully do simple evaluations like "x <- matrix(1:9,nrow=3)" or "print(x)" but I can't call any function from stats or attaching other libraries like MASS.


I'm using:
R 3.0.0
Visual Studio 2010
.NET framework 4.0
R.NET 1.5


Thank you for your help.
Jun 12, 2013 at 5:06 PM
Does anybody have any suggestion about how I can solve the problem above?
Developer
Jun 14, 2013 at 8:29 AM
Is your C# program run as a 32 or 64 bits program? LoadLibrary failures are often relating to that. Then again I don;t think you could run anything if this was the issue.

Getting the information from engine.Evaluate for the following R statements would help to diagnose.
Sys.getenv('R_HOME')
.libPaths()
Sys.getenv('R_LIBS')
Sys.getenv('R_LIBS_USER')
Sys.getenv('R_ARCH')
Although it refers to R.NET 1.4, you may want to look at https://rdotnet.codeplex.com/discussions/352799 for how to set environment variables.
Jun 14, 2013 at 3:45 PM
The C# program is a 32bit program.
Here is the statements and their result:
Sys.getenv('R_HOME')
[1] "C:/Program Files/R/R-3.0.0"

.libPaths()
[1] "C:/Program Files/R/R-3.0.0/library"

Sys.getenv('R_LIBS')
[1] ""

Sys.getenv('R_LIBS_USER')
[1] "C:/Documents and Settings/frd/My Documents/R/win-library/3.0"

Sys.getenv('R_ARCH')
[1] "/i386"
Jun 19, 2013 at 7:49 AM
hi!
I tried RDotNet 1.4 + R 3.0.1 + VS2010 and have the same issue. Anybody know how to solve this?
Developer
Jun 20, 2013 at 12:48 AM
I cannot help further as I am unable to reproduce the issue

The only thing I can think of to explain:
unable to load shared object ‘C:/Program Files/R/R-3.0.0/library/stats/libs/i386/stats.dll’:
LoadLibrary failure: The specified module could not be found.
is a 64 bits process trying to load a 32 bits library.
As a last resort, one may try to prepend to the PATH environment variable in a custom .First R function in your startup. Even then the R startup process probably builds the specific path to 'C:/Program Files/R/R-3.0.0/library/stats/libs/i386/stats.dll’ to load.

The R startup process is at.
?Startup
?.First
?.First.sys
@ dselivanov I'd recommend you use the 1.5 library.
Jun 20, 2013 at 2:22 PM
Edited Jun 20, 2013 at 2:23 PM
Today after hours of play around with PATH variable in visual studio i add string "c:\Program Files\R\R-3.0.1\bin\i386;c:\Program Files\R\R-3.0.1\bin;" into path variable in windows. Like in (3) in R for Windows FAQ
Now it works well.
Mar 23, 2015 at 5:22 PM
I had the same problem with 1.5.22. The trick with adding "c:\Program Files\R\R-3.0.1\bin\i386" to the Windows path permanently worked. Note that in my case adding of just one path of the two above is enough.

The problem is solved. But this took a while! Note that I tried to add the same path to the current process %PATH%. This does not work.

I would suggest to mention this issue in the manuals and point to a possible solution.