| 1 |
\name{pkgDesc} |
| 2 |
\title{Version of packageDescription() as Simple Vector} |
| 3 |
\alias{pkgDesc} |
| 4 |
\alias{pkgBuilt} |
| 5 |
\description{ |
| 6 |
a simple \dQuote{version}, or wrapper for |
| 7 |
\code{\link{packageDescription}()}, returning a named character vector, |
| 8 |
including \code{"file"}, and still has a useful \code{\link{print}()} |
| 9 |
method. |
| 10 |
} |
| 11 |
\usage{ |
| 12 |
pkgDesc (pkg, lib.loc = NULL, fields = NULL, onlyLT = 99, ...) |
| 13 |
pkgBuilt(pkg, lib.loc = NULL, ...) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{pkg}{a \code{\link{character}} string, name of an installed \R package.} |
| 17 |
\item{lib.loc}{library location to find the package in; the default |
| 18 |
\code{NULL} uses the full \code{\link{.libPaths}()}.} |
| 19 |
\item{fields}{a character vector (or \code{NULL}) specifying fields to be returned.} |
| 20 |
\item{onlyLT}{positive integer specifying an upper limit on the number of |
| 21 |
characters of fields to be returned and printed.} |
| 22 |
\item{...}{further optional arguments passed to \code{\link{packageDescription}()}.} |
| 23 |
} |
| 24 |
\value{ |
| 25 |
a named \code{\link{character}} vector, with \code{\link{names}}, the |
| 26 |
\emph{fields}, identical to the names of the \code{\link{list}} returned |
| 27 |
by \code{\link{packageDescription}}, plus its \code{"file"} attribute. |
| 28 |
Additionally the resulting vector is of class \code{"Dlist"} which |
| 29 |
activates a useful \code{\link{print}()} method. |
| 30 |
} |
| 31 |
\author{Martin Maechler, Jan. 2021} |
| 32 |
\note{The \code{file} is always returned; not the least that the author |
| 33 |
wants to see it quite often as his \code{\link{.libPaths}()} is |
| 34 |
non-trivial and typically longer than 4 entries. |
| 35 |
|
| 36 |
I started to hate screen fulls of Authors and/or Description; when I |
| 37 |
wanted quite basic info, hence \code{onlyLT} with a reasonable default. |
| 38 |
} |
| 39 |
\seealso{ |
| 40 |
\code{\link{packageDescription}}, |
| 41 |
\code{\link{.libPaths}}. |
| 42 |
} |
| 43 |
\examples{ |
| 44 |
str(pd <- pkgDesc("sfsmisc")) |
| 45 |
pd[c("Date","Packaged", "Built","file")] |
| 46 |
|
| 47 |
## see the effects of `onlyLT` : |
| 48 |
str(p1 <- pkgDesc("sfsmisc", onlyLT = Inf)) # .. [1:25] .. |
| 49 |
str(pD <-pkgDesc("sfsmisc" )) # .. [1:21] .. |
| 50 |
str(p50 <-pkgDesc("sfsmisc", onlyLT = 50 )) # .. [1:18] .. |
| 51 |
t(sapply(list(full = p1, def. = pD, p50 = p50), |
| 52 |
function(pd) {n <- nchar(pd); c(summary(n)[-1], SUM = sum(n))})) |
| 53 |
|
| 54 |
pkgBuilt("sfsmisc") |
| 55 |
|
| 56 |
## Show "Built" (and "file") for all packages whose namespaces are loaded: |
| 57 |
lNs <- loadedNamespaces() |
| 58 |
mlNs <- sapply(lNs, pkgBuilt) |
| 59 |
t(mlNs) # typically prints nicely |
| 60 |
|
| 61 |
pkgs <- c("grid", "lattice", "MASS", "Matrix", "nlme", "lme4", "sfsmisc") |
| 62 |
pkgs <- c("foobar", "barbar", pkgs, "kitty") # + names that typically don't exist |
| 63 |
pkgsOk <- basename(find.package(pkgs, quiet=TRUE)) |
| 64 |
mpkg <- sapply(pkgsOk, pkgBuilt) |
| 65 |
stopifnot(is.matrix(mpkg), nrow(mpkg) == 2) |
| 66 |
t(mpkg["Built", , drop=FALSE]) # as 1-column matrix for readibility |
| 67 |
} |