[Rd] Fwd: Bug: argument 'lib.loc' not passed on appropriately in 'library()'?

From: Janko Thyson <janko.thyson.rstuff_at_googlemail.com>
Date: Thu, 18 Aug 2011 20:20:19 +0200

Sorry, embarrassing stupid error: of course '.libPaths(path.r.lib)' will do the trick for me.

Regards,
Janko

Dear list,

I'm experimenting with setting up custom 'lib' and 'destdir' directories for my R packages. It seems to me that 'library()' does handle a custom 'lib.loc' argument the way it should for an arbitrary package but NOT for its dependencies on other packages. The latter are looked for in the default lib path (~/R/R-2.x.x/library) and NOT in the custom lib path.

Below is a little code example illustrating the error I'm getting. It'd be great if someone could validate this.

Thanks a lot for any comments,
Janko

### CODE EXAMPLE ###
# Package that I'm sure of that it's not already installed and has
dependencies
pkg<- "rworldmap"

# Making sure that dependencies are not available in the default library

remove.packages("sp")
remove.packages("maptools")
remove.packages("foreign")
remove.packages("lattice")

# Setting custom lib and destdir
path.r.lib<- "C:/temp/R/library"
dir.create(path.r.lib, recursive=TRUE, showWarning=FALSE) path.r.destdir<- "C:/temp/R/destdir"
dir.create(path.r.destdir, recursive=TRUE, showWarning=FALSE)

# Core processing

try.res<- try(

     eval(substitute(
         library(PKG, lib.loc=path.r.lib, verbose=FALSE),
         list(PKG=pkg)
     )),
     silent=TRUE

)
if(inherits(try.res, "try-error")){
     msg<- c(
         paste("Required package '", pkg, "' not available locally",
sep=""),
         paste("Looking for package '", pkg, "' in remote repository",
sep="")
     )
     cat(msg, sep="\n")
     install.packages(
         pkg,
         repos=getOption("repos"),
         lib=path.r.lib,
         destdir=path.r.destdir,
         dependencies="Depends"
     )
     eval(substitute(
         library(PKG, lib.loc=path.r.lib, verbose=FALSE),
         list(PKG=pkg)
     ))

# Here's where the error occurs. Seems to me that 'lib.loc' is not really
# passed on appropriately within 'library()', but instead the default
lib path
# is used to look for dependencies.
}

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 18 Aug 2011 - 18:22:37 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 18 Aug 2011 - 23:40:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive