[R] Using library and lib.loc

Martin Maechler maechler at stat.math.ethz.ch
Fri Sep 3 10:01:30 CEST 2010


>>>>> "o" == omerle  <omerle at laposte.net>
>>>>>     on Thu,  2 Sep 2010 10:30:49 +0200 (CEST) writes:

    o> Hi,
    o> I didn't find any post on this subject so I ll ask you some advices.

    o> Let's say that I have two library trees.

    o> Number 1 is the default R library tree on path1
    o> Number 2 is another library tree on a server with all packages on path2.

    o> When I set library(aaMI,lib.loc=paths2) it loads the package even if its not on default R library
    o> When I set library(fOptions,lib.loc=paths2) it doesn't load because timeSeries is not on default R library (timeSeries is a required package for fOptions)

    >> library(fOptions,lib.loc=.lib.loc)
    o> Le chargement a nécessité le package : timeDate
    o> Le chargement a nécessité le package : timeSeries
    o> Erreur : le package 'timeSeries' ne peut être chargé
    o> De plus : Message d'avis :
    o> In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) :
    o>   aucun package nommé 'timeSeries' n'est trouvé

    o> (Sorry for french error message. By the way, how can I set error in French (setting language in English in R installation is not sufficient !)

    o> How can I set lib.loc for every package that I will load ?
    o> Or is there any global way of doing this ?

There are several possibilities ..

You can set  .libPaths() in your Rprofile
or you can set R_LIBS in your    Renviron
and there are variations and combinations of the above.

See ?Startup to learn about Rprofile and Renviron settings.

Martin Maechler, ETH Zurich


    o> Thanks,
    o> Olivier



More information about the R-help mailing list