[R] library(): load library from a specified location

Duncan Murdoch murdoch at stats.uwo.ca
Tue Mar 30 13:16:25 CEST 2010


On 30/03/2010 7:01 AM, Jannis wrote:
> Dear list memmbers,
> 
> 
> I would like to load a R library from a specified folder with library()
> and need help on how to call the command.
> 
> The reason is that I am loading this library on a remote machine where I
>   have no admin rights. Furthermore a library with the same name is
> already installed on that machine. I have modified this library slightly
> by modifying the source code and created a "personal" version of this
> library that I now want to load instead of the standart one.
> 
> Running:
> 
> R CMD INSTALL 'path*/*packagename* --library=*path*/Software/R-packages
> 
> 
> i managed to compile my modified version on the remote machine and save
> the library in a folder on that machine.
> 
> 
> When I now start R and run
> 
> library(packagename)
> 
> 
> R still seem to load the version installed on the remote computer, even 
> though
> i added my folder to the library path of R by running:
> 
> .libPaths("*path*/Software/R-Packages")
> 
> Probably this is due to the fact that the package is also available in 
> the standart library of R.
> Ist there any way of loading the Package from only one specified path? I 
> read the help for library() and could imagine that lib.loc could be the 
> key to sucess but am not sure which argument it needs?

Is the package loaded before you make the change to .libPaths?  The base 
packages are loaded at startup, but this can be suppressed:  see ?Startup.

If that's not it, then I think we need more specific information, 
because what you're doing should work.  Show us the result of

sessionInfo()
.libPaths("*path*/Software/R-Packages")
.libPaths()
library(packagename)
sessionInfo()



Duncan Murdoch



More information about the R-help mailing list