[R] finding libraries with command line Rterm.exe (from tcl/tk )
Wolfgang Raffelsberger
wraff at titus.u-strasbg.fr
Fri Oct 5 21:19:06 CEST 2007
Dear all,
Let me reformulate my question from my previous post (thanks to Brian
Ripley for the hint but this didn't help me to resolve the problem).
I'll try to be more precise :
I have installed R-2.6.0 in a Windows Vista machine using default
settings (so R is under C:\Program Files ).
Then, running R in the "regular" mode under Vista I've installed the
library RODBC (to give an example). As by default any user is running R
not as administrator, additional libraries (like RODBC in this case)
don't get installed under the main tree of R (which is on C:\Program
Files\R ) but in the user's home
(C:\Users\wr\Contacts\Documents\R\win-library\2.6).
Under normal circumstances R manages to locate such additional libraries
(RODBC) in .libPaths() .
> .libPaths()
[1] "C:\\Users\\wr\\Contacts\\Documents/R/win-library/2.6"
[2] "C:/PROGRA~1/R/R-26~1.0/library"
However, I'm calling R from within a tcl/tk script (of course still as
the same user-login), and .libPaths() doesn't find the path to the
additional library (RODBC, which is located in ) any more.
> .libPaths()
[1] "C:/PROGRA~1/R/R-26~1.0/library"
I agree with Brian that my way of calling R seems to be the crucial point.
It is :
Rterm.exe --vanilla -q < myRcode.r
i.e. the full line reads as :
catch {eval exec Rterm.exe --vanilla -q < $nomFicRtmp} msg1
since I also recuperate the messages R might display during execution of
my R-code.
If I understand the documentation for ?Startup correctly, "--vanilla"
works like a "shortcut" instead of writing the all attributes
"--no-site-file","--no-init-file", "--no-restore", "--no-environ" and
"--no-Rconsole".
Strangely when opening a DOS command-line window and launching
"Rterm.exe --vanilla" still allows me to find both library-paths with
.libPaths(), even though now R should look only in
R_HOME/etc/Rprofile.site . But the file Rprofile.site doesn't contain
the path to my additional library (RODBC) ?!
Of course, I could add the path "as it is" in the code when calling a
library, but then the program would work only for me, and that's not
what I want.
On an earlier posting on this list (8 jan 07, "scripts with littler")
I've seen that
R --slave --vanilla < myRcode.r
was suggested for allowing R under Linux to find libraries installed in
the user's home, which resembles to my problem.
Unfortunately, adding the "--slave" argument didn't resolve my problem
under Vista.
Also I couldn't find documentation what "--slave" does and if there are
other arguments besides those mentioned in ?Startup.
Basically I'd like to find a way to keep/force Rterm.exe to use the
(regular) _environement files_ , particularly concerning the R_LIBS .
This means :
Is there a way to execute command-line Rterm.exe (from tcl/tk) without
the necessity that all libraries MUST be installed ONLY in R_HOME ?
I guess using the _environement files_ (mentioned in ?Startup) might be
much better choice than constructing the most likely library-path in tcl
& declaring as R_LIBS, since the slightest change in directory-names
would make this worthless.
Where can I find more information about the _environement files_ or R
(mentioned in ?Startup) ?
In this context I'd also be interested to know where these environment
variables are saved (I assume they are written to one/serveral files).
I've checked all files in R_HOME\bin and R_HOME\etc, but (obviously)
it's not saved anywhere there and I haven't pierced the mystery of Vista
to see where in user-home this might be saved.
Thanks in advance,
Wolfgang Raffelsberger
Prof Brian Ripley a écrit :
> On Thu, 4 Oct 2007, Wolfgang Raffelsberger wrote:
>
>> Dear list,
>>
>> I?m using R embedded in another program (coded in tcl/tk) under Windows
>> Vista. In this context I don?t launch Rgui.exe but rather Rtem.exe.
>>
>>
>> Now I have a problem finding libraries not specifically installed as
>> administrator (and which are not in the path ?program files? but in
>> Contacts\Documents of the current user). To be precise, the user
>> launching my tcl/tk program can?t find the libraries he previously
>> installed locally (as Vista does by default when not launched
>> specifically with administrator rights).
>>
>> However, when (manually) launching Rterm.exe directly (or R.exe) the
>> command .libPaths() returns correctly 2 locations (the personal local
>> library and the ?common? one in ?program files?) as it does with
>> RGui.exe .
>>
>> Does anyone have an idea how or why I can?t see the location of the
>> additional libraries ?
>
> You mean the additional library what contains packages? It really
> does help to get your terminology straight here.
>
> What libraries are on .libPaths() is controlled by environment
> variables, so debugging those will be the key. This is all explained
> on the help page for .libPaths.
>
>
>> Could it be a problem with the attributes of : Rterm.exe --vanilla -q <
>> myRcode.r
>
> Yes, it could. Look up what --vanilla does in ?Startup: it skips
> places where the environment variables are usually set.
>
>>
>> (Note that I had no difficulties with these attributes calling R under
>> Win XP or Linux, but never faced the problem of multiple locations for
>> libraries.)
>>
>>
>> please find below the code form *(a)* launching : Rterm.exe ?vanilla ?q
>> < myRcode.r (where ?local? libs are *NOT found*) :**
>>
>>> .libPaths()
>>
>> "C://PROGRA~1/R/R-26~1.0/library"
>>
>>> require(affy)
>>
>> Le chargement a nécessité le package : affy
>>
>> Warning messages:
>>
>> 1: In library(package, lib.loc = lib.loc, character.only = TRUE,
>> logical.return = TRUE, :
>>
>> aucun package nommé 'affy' n'est trouvé
>>
>> > # this translates into "no package called "affy" was found"
>>
>>> sessionInfo()
>>
>> R version 2.6.0 (2007-10-03)
>>
>> i386-pc-mingw32
>>
>> locale:
>>
>> LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERattached
>>
>> base packages:
>>
>> [1] stats graphics grDevices utils datasets methods base
>>
>>
>>
>>
>> and the code from (b) manually launching : Rterm.exe (where ?local? libs
>> are found OK) :
>>
>>> .libPaths()
>>
>> [1] "C:\\Users\\wr\\Contacts\\Documents/R/win-library/2.6"
>>
>> [2] "C:/PROGRA~1/R/R-26~1.0/library"
>>
>>>
>>
>>> require(affy) # was NOT installed in : program files/...
>>
>> Le chargement a nécessité le package : affy
>>
>> Le chargement a nécessité le package : Biobase
>>
>> Le chargement a nécessité le package : tools
>>
>> Welcome to Bioconductor
>>
>> Vignettes contain introductory material. To view, type
>>
>> 'openVignette()'. To cite Bioconductor, see
>>
>> 'citation("Biobase")' and for packages 'citation(pkgname)'.
>>
>> Le chargement a nécessité le package : affyio
>>
>> Le chargement a nécessité le package : preprocessCore
>>
>>>
>>
>>> sessionInfo()
>>
>> R version 2.6.0 (2007-10-03)
>>
>> i386-pc-mingw32
>>
>> locale:
>>
>> LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252
>>
>>
>> attached base packages:
>>
>> [1] stats graphics grDevices utils datasets methods base
>>
>> As you can see only a single path is found, which is the default
>> collection of libraries in the path of the R installation itself.
>>
>> Does anyone have an idea how I could identify the libPath for a given
>> user and by which argument added to R.exe I could allow accessing these
>> libraries, too ?
>>
>> Thanks? in advance,
>> Wolfgang Raffelsberger
>>
>>
>> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
>> . . .
>>
>> Wolfgang Raffelsberger, PhD
>> Laboratoire de BioInformatique et Génomique Intégratives
>> IGBMC
>> 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France
>> Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
>> wolfgang.raffelsberger at igbmc.u-strasbg.fr
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC
1 rue Laurent Fries, 67404 Illkirch Strasbourg, France
Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger at igbmc.u-strasbg.fr
More information about the R-help
mailing list