This project is read-only.

Library in a different folder in vb

Jun 3, 2013 at 3:16 PM
For my application I need to use drc, a library of R, but it is stocked in MyDocuments and not in R folder, How can I do to ask R to use it ?

How to do this in :
library("drc", lib.loc="C:/Users/compte de secours/Documents/R/win-library/2.15")
Jun 4, 2013 at 8:34 AM
Edited Jun 4, 2013 at 8:35 AM
An R engine that has properly initialized should pick this up (i.e. this path should be present in .libPath(), and:
from R or R.NET Rengine.Evaluate should work.
I am not sure this is what you ask for. Is the R line you give working from R but not from R.NET?

As a last resort setting an environment variable R_LIBS can specify a particular path to look in. I actually use this personally.
> Sys.getenv('R_LIBS')
[1] "f:/Rlib"
Jun 4, 2013 at 9:03 AM
The line i gave works on R but not on, actually, I use R studio and when i checked drc package, this is the line it use to open it. I tried to put "C:/Users/compte de secours/Documents/R/win-library" as .libPath() but it doesn't works.
Jun 4, 2013 at 9:32 AM
Edited Jun 4, 2013 at 9:38 AM
My library drc need other libraries to work, if I initialize them before, could it works better ?
Le chargement a nécessité le package : alr3
Le chargement a nécessité le package : car
Le chargement a nécessité le package : MASS
Le chargement a nécessité le package : nnet

Attachement du package : ‘alr3’

The following object(s) are masked from ‘package:MASS’:


Le chargement a nécessité le package : gtools

Attachement du package : ‘gtools’

The following object(s) are masked from ‘package:car’:


Le chargement a nécessité le package : lattice
Le chargement a nécessité le package : magic
Le chargement a nécessité le package : abind
Le chargement a nécessité le package : nlme
Le chargement a nécessité le package : plotrix
Le chargement a nécessité le package : stats4

'drc' has been loaded.

Please cite R and 'drc' if used for a publication,
for references type 'citation()' and 'citation('drc')'.

Attachement du package : ‘drc’

The following object(s) are masked from ‘package:stats’:

Jun 14, 2013 at 12:04 PM

I cannot reproduce your issue. While looking at I basically tested something similar to your situation by loading some packages which I have installed in a 'personal' folder. Not quite the same setup as you, but close.

I have logged an issue to try to look at it further.
Jun 14, 2013 at 12:47 PM
I cannot reproduce your issue. the code below, for a standard user with drc in the personal library folder, works.

The script below outputs, as expected from a session in RGui:
C:/Program Files/R/R-3.0.0/library
            // Set the folder in which R.dll locates.
            var envPath = Environment.GetEnvironmentVariable("PATH");
            var rBinPath = @"C:\Program Files\R\R-3.0.0\bin\i386";
            Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
            using (REngine engine = REngine.CreateInstance("RDotNet"))
                // Initializes settings.
                engine.Evaluate("?drc::actimL");           // Note: Interesting this does not trigger firefox...
                engine.Evaluate("ryegrass.LL.4 <- drm(rootl~conc, data=ryegrass, fct=LL.4())");
                var blah = engine.Evaluate("backfit(ryegrass.LL.4)").AsNumericMatrix();
                var libPaths = engine.Evaluate(".libPaths()").AsCharacter().ToArray();
                foreach (var item in libPaths)
hope this still helps.
Jun 14, 2013 at 12:56 PM
Edited Jun 14, 2013 at 1:20 PM
Thank you, I will try this, i did'nt see your last post before posting.

Edit : I translate it in a version and : I have to add this or else it doesn't work. And also not use engine.initialize() ? it is not recognized.
REngine.SetDllDirectory("C:\Program Files\R\R-2.15.2\bin\i386")
And finally, it doesn't work, same error in the same place...

Here is my code :
Dim envPath = System.Environment.GetEnvironmentVariable("PATH")
        Dim rBinPath = "C:\Program Files\R\R-3.0.0\bin\i386"
        System.Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath)
        REngine.SetDllDirectory("C:\Program Files\R\R-2.15.2\bin\i386")
        Dim engine = REngine.CreateInstance("RDotNet")
Jun 14, 2013 at 11:26 PM

I should have mentioned I used version 1.5 . I'd recommend you use it too, either getting it via nu-get or from source. (not that I think this will definitely make a difference to your problem)

I am not sure why version 1.4 is still available as a download really; most people use it in preference to getting the latest via nu-get. I'll get in touch with Kosei see what is the intent.

Jun 17, 2013 at 9:01 AM
Thank you this was the good way to fixe my case !
I tried the two last version and the 3.0.0 works ! But not the 3.0.1.

Thank you for your help and for R.NET