[R] Local install of a contributed package under Linux (was: R-code for binormla distribution)

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 3 09:12:39 CEST 2005


On Sun, 2 Oct 2005, Jonathan Baron wrote:

> Try
>
> R CMD INSTALL -l lib pkgs
>
> The help file is in the utils package.  I'm sure this is
> documented in the manual too.

But you still need to ensure that library() can find the packages.


I think the simplest way is that we have set up by default for new R 
users:

1) Set the environment variable R_LIBS.  For a site in 
R_HOME/etc/Renviron.site, or for a user in ~/.Renviron.  For example,
include the line

R_LIBS=~/R/library

2) Ensure that this directory exists, e.g.

mkdir -p ~/R/library

(If it does not exist the setting will be ignored, so it is safe to set it 
for all users.)

3) Use install.packages() inside R.  This will by default use the first 
element in .libPaths(), which will be ~/R/library.  Suggest to users that 
they use would do best to use

install.packages(pkgs, .libPaths()[1], dependencies = TRUE)

when they want to add packages, and update.packages(.libPaths()[1]) to 
update the packages they have installed.

Note that this works for Windows users too (although using ~ is perhaps 
dependent on setting HOME:  our Windows default use the network drive P: 
instead).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list