Learn R Programming

sfsmisc (version 1.1-23)

pkgDesc: Version of packageDescription() as Simple Vector

Description

a simple “version”, or wrapper for packageDescription(), returning a named character vector, including "file", and still has a useful print() method.

Usage

pkgDesc (pkg, lib.loc = NULL, fields = NULL, onlyLT = 99, ...)
pkgBuilt(pkg, lib.loc = NULL, ...)

Value

a named character vector, with names, the

fields, identical to the names of the list returned by packageDescription, plus its "file" attribute. Additionally the resulting vector is of class "Dlist" which activates a useful print() method.

Arguments

pkg

a character string, name of an installed R package.

lib.loc

library location to find the package in; the default NULL uses the full .libPaths().

fields

a character vector (or NULL) specifying fields to be returned.

onlyLT

positive integer specifying an upper limit on the number of characters of fields to be returned and printed.

...

further optional arguments passed to packageDescription().

Author

Martin Maechler, Jan. 2021

See Also

Examples

Run this code
str(pd <- pkgDesc("sfsmisc"))
pd[c("Date","Packaged", "Built","file")]

## see the effects of  `onlyLT` :
str(p1 <- pkgDesc("sfsmisc", onlyLT = Inf)) # .. [1:25] ..
str(pD  <-pkgDesc("sfsmisc"              )) # .. [1:21] ..
str(p50 <-pkgDesc("sfsmisc", onlyLT = 50 )) # .. [1:18] ..
t(sapply(list(full = p1, def. = pD, p50 = p50),
         function(pd) {n <- nchar(pd); c(summary(n)[-1], SUM = sum(n))}))

pkgBuilt("sfsmisc")

## Show "Built" (and "file") for all packages whose namespaces are loaded:
lNs <- loadedNamespaces()
mlNs <- sapply(lNs, pkgBuilt)
t(mlNs) # typically prints nicely

pkgs <- c("grid", "lattice", "MASS", "Matrix", "nlme", "lme4", "sfsmisc")
pkgs <- c("foobar", "barbar", pkgs, "kitty") # + names that typically don't exist
pkgsOk <- basename(find.package(pkgs, quiet=TRUE))
mpkg <- sapply(pkgsOk, pkgBuilt)
stopifnot(is.matrix(mpkg), nrow(mpkg) == 2)
mpkg["Built",]

Run the code above in your browser using DataLab