installed.packages {utils} | R Documentation |
Find Installed Packages
Description
Find (or retrieve) details of all packages installed in the specified libraries.
Usage
installed.packages(lib.loc = NULL, priority = NULL,
noCache = FALSE, fields = NULL,
subarch = .Platform$r_arch, ...)
Arguments
lib.loc |
character vector describing the location of R library trees to
search through, or |
priority |
character vector or |
noCache |
Do not use cached information, nor cache it. |
fields |
a character vector giving the fields to extract from
each package's ‘DESCRIPTION’ file in addition to the default
ones, or |
subarch |
character string or |
... |
allows unused arguments to be passed down from other functions. |
Details
installed.packages
scans the ‘DESCRIPTION’ files of each
package found along lib.loc
and returns a matrix of package
names, library paths and version numbers.
The information found is cached (by library) for the R session and
specified fields
argument, and updated only if the top-level
library directory has been altered, for example by installing or
removing a package. If the cached information becomes confused, it
can be avoided by specifying noCache = TRUE
.
Value
A matrix with one row per package, row names the package names and
column names (currently)
"Package"
, "LibPath"
,
"Version"
, "Priority"
,
"Depends"
, "Imports"
, "LinkingTo"
,
"Suggests"
, "Enhances"
,
"OS_type"
, "License"
and
"Built"
(the R version the package was built under).
Additional columns can be specified using the fields
argument.
Note
This needs to read several files per installed package, which will be slow on Windows and on some network-mounted file systems.
It will be slow when thousands of packages are installed, so do not
use it to find out if a named package is installed (use
find.package
or system.file
) nor to find
out if a package is usable (call requireNamespace
or
require
and check the return value) nor to find details
of a small number of packages (use packageDescription
).
See Also
update.packages
,
install.packages
,
INSTALL
, REMOVE
.
Examples
## confine search to .Library for speed
str(ip <- installed.packages(.Library, priority = "high"))
ip[, c(1,3:5)]
plic <- installed.packages(.Library, priority = "high", fields = "License")
## what licenses are there:
table( plic[, "License"] )
## Recommended setup (by many pros):
## Keep packages that come with R (priority="high") and all others separate!
## Consequently, .Library, R's "system" library, shouldn't have any
## non-"high"-priority packages :
pSys <- installed.packages(.Library, priority = NA_character_)
length(pSys) == 0 # TRUE under such a setup