The R Project SVN R

Rev

Rev 61433 | Rev 64657 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/libPaths.Rd
2
% Part of the R package, http://www.R-project.org
60234 ripley 3
% Copyright 1995-2012 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
30722 ripley 6
\name{libPaths}
7
\title{Search Paths for Packages}
8
\alias{.Library}
40248 ripley 9
\alias{.Library.site}
30722 ripley 10
\alias{.libPaths}
41341 hornik 11
\alias{R_LIBS}
12
\alias{R_LIBS_SITE}
13
\alias{R_LIBS_USER}
41159 ripley 14
\alias{.expand_R_libs_env_var}
30722 ripley 15
\description{
16
  \code{.libPaths} gets/sets the library trees within which packages are
17
  looked for.
18
}
19
\usage{
20
.libPaths(new)
21
 
22
.Library
40248 ripley 23
.Library.site
30722 ripley 24
}
25
\arguments{
40248 ripley 26
  \item{new}{a character vector with the locations of \R library
40264 ripley 27
    trees.  Tilde expansion (\code{\link{path.expand}}) is done, and if
28
    any element contains one of \code{*?[}, globbing is done where
40281 ripley 29
    supported by the platform: see \code{\link{Sys.glob}}.}
30722 ripley 30
}
31
\details{
32
  \code{.Library} is a character string giving the location of the
47259 ripley 33
  default library, the \file{library} subdirectory of \env{R_HOME}.
30722 ripley 34
 
40248 ripley 35
  \code{.Library.site} is a (possibly empty) character vector giving the
36
  locations of the site libraries, by default the \file{site-library}
47259 ripley 37
  subdirectory of \env{R_HOME} (which may not exist).
40248 ripley 38
 
30722 ripley 39
  \code{.libPaths} is used for getting or setting the library trees that
40
  \R knows about (and hence uses when looking for packages).  If called
41
  with argument \code{new}, the library search path is set to
40248 ripley 42
  the existing directories in \code{unique(c(new, .Library.site, .Library))}
43
  and this is returned.  If given no argument, a character vector with
44
  the currently active library trees is returned.
30722 ripley 45
 
46
#ifdef unix
47
  The library search path is initialized at startup from the environment
47259 ripley 48
  variable \env{R_LIBS} (which should be a colon-separated list of
40248 ripley 49
  directories at which \R library trees are rooted) followed by those in
47259 ripley 50
  environment variable \env{R_LIBS_USER}.  Only directories which exist
40248 ripley 51
  at the time will be included.
52
 
47259 ripley 53
  By default \env{R_LIBS} is unset, and \env{R_LIBS_USER} is set to
54
  directory \file{R/\var{R.version$platform}-library/\var{x.y}}
46650 urbaneks 55
  of the home directory (or \file{Library/R/\var{x.y}/library} for
62176 ripley 56
  CRAN OS X builds), for \R \var{x.y.z}.
40255 ripley 57
 
61433 ripley 58
  \code{.Library.site} can be set via the environment variable
60234 ripley 59
  \env{R_LIBS_SITE} (as a non-empty colon-separated list of library trees).
30722 ripley 60
#endif
61
#ifdef windows
62
  The library search path is initialized at startup from the environment
47259 ripley 63
  variable \env{R_LIBS} (which should be a semicolon-separated list of
40248 ripley 64
  directories at which \R library trees are rooted) followed by those in
47259 ripley 65
  environment variable \env{R_LIBS_USER}.  Only directories which exist
40248 ripley 66
  at the time will be included.
67
 
47259 ripley 68
  By default \env{R_LIBS} is unset, and \env{R_LIBS_USER} is set to
40248 ripley 69
  subdirectory \file{R/win-library/\var{x.y}} of the home directory,
70
  for \R \var{x.y.z}.
40255 ripley 71
 
72
  \code{.Library.site} can be set via the environment variable
60234 ripley 73
  \env{R_LIBS_SITE} (as a non-empty semicolon-separated list of library trees).
30722 ripley 74
#endif
40240 ripley 75
 
47259 ripley 76
  Both \env{R_LIBS_USER} and \env{R_LIBS_SITE} feature possible
41155 hornik 77
  expansion of specifiers for \R version specific information as part of
78
  the startup process.  The possible conversion specifiers all start
79
  with a \samp{\%} and are followed by a single letter (use \samp{\%\%}
80
  to obtain \samp{\%}), with currently available conversion
81
  specifications as follows:
82
  \describe{
49612 hornik 83
    \item{\samp{\%V}}{\R version number including the patchlevel (e.g.,
41155 hornik 84
      \samp{2.5.0}).}
49612 hornik 85
    \item{\samp{\%v}}{\R version number excluding the patchlevel (e.g.,
41155 hornik 86
      \samp{2.5}).}
49612 hornik 87
    \item{\samp{\%p}}{the platform for which \R was built, the value of
47728 ripley 88
      \code{\link{R.version}$platform}.}
49612 hornik 89
    \item{\samp{\%o}}{the underlying operating system, the value of
47728 ripley 90
      \code{\link{R.version}$os}.}
49612 hornik 91
    \item{\samp{\%a}}{the architecture (CPU) \R was built on/for, the
47728 ripley 92
      value of \code{\link{R.version}$arch}.}
41155 hornik 93
  }
94
  (See \code{\link{version}} for details on R version information.)
95
 
40248 ripley 96
  Function \code{.libPaths} always uses the values of \code{.Library}
56382 murdoch 97
  and \code{.Library.site} in the base namespace.  \code{.Library.site}
40248 ripley 98
  can be set by the site in \file{Rprofile.site}, which should be
99
  followed by a call to \code{.libPaths(.libPaths())} to make use of the
100
  updated value.
54860 ripley 101
 
102
  For consistency, the paths are always normalized by
61150 ripley 103
  \code{\link{normalizePath}(winslash = "/")}.
30722 ripley 104
}
105
\value{
106
  A character vector of file paths.
107
}
108
\references{
109
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
110
  \emph{The New S Language}.
47262 ripley 111
  Wadsworth & Brooks/Cole.
30722 ripley 112
}
113
\seealso{
114
  \code{\link{library}}
115
}
116
\examples{
117
.libPaths()                 # all library trees R knows about
118
}
119
\keyword{data}