
Last chance! 50% off unlimited learning
Sale ends in
Obtain a summary by package of a findFn
object give it class packageSum
.
This is a simple function, first calling
PackageSum2
, than assigning
class packagesum
to it.
packageSum(x,
fields=c("Title", "Version", "Author", "Maintainer",
"Packaged", 'helpPages', 'vignette', 'URL'),
lib.loc=NULL, ...)
# S3 method for findFn
packageSum(x,
fields=c("Title", "Version", "Author", "Maintainer",
"Packaged", 'helpPages', 'vignette', 'URL'),
lib.loc=NULL, ...)
# S3 method for data.frame
packageSum(x,
fields=c("Title", "Version", "Author", "Maintainer",
"Packaged", 'helpPages', 'vignette', 'URL'),
lib.loc=NULL, ...)
# S3 method for list
packageSum(x,
fields=c("Title", "Version", "Author", "Maintainer",
"Packaged", 'helpPages', 'vignette', 'URL'),
lib.loc=NULL, ...)
a data.frame with columns Package
and Score
.
character vector of names of columns to add to x
.
The function first looks in the components of
packageDescription(x$Package[i])
. 'vignette' is
obtained via the function of that name.
Component 'Packaged' receives special treatment. If
present, only the portion preceding ';' will be retained.
This seems to be a time stamp automatically generated by
something like R CMD build
. It is absent for
packages automatically loaded when R is started. In such
cases, the third component of
strsplit(packageDescription( x$Package[i])$Built,
..., ';')
will be stored as 'Packaged'. This seems to be
a time stamp automatically generated by something like
R CMD INSTALL --build
.
an optional lib.loc
argument passed to
packageDescription
.
additional arguments (currently unused)
a data.frame
of class
c('packageSum', 'data.frame').
With an object of class findFn
, call
PackageSum2
, then make it class
packageSum
.
If less than half of the package reference are
installed, it prints a note suggesting the
user call installPackages
, because
much of the information is obtained from
the packages' DESCRIPTION
file.
# NOT RUN {
##
## data.frame method
##
tstdf <- data.frame(Package=c('grid', 'base'),
stringsAsFactors=FALSE)
tst2 <- packageSum(tstdf)
##
## list method
##
tstList <- list(PackageSummary=tstdf)
# }
# NOT RUN {
all.equal(tst2, packageSum(tstList))
# }
# NOT RUN {
##
## findFn method
##
tst.findFn <- data.frame(
Package=c('grid', 'base')[c(1,1,2)],
Score=2:4, Date=LETTERS[1:3], stringsAsFactors=FALSE)
attr(tst.findFn, 'PackageSummary') <-
PackageSummary(tst.findFn)
class(tst.findFn) <- c('findFn', 'data.frame')
tst2. <- packageSum(tst.findFn)
# }
# NOT RUN {
all.equal(tst2, tst2.[names(tst2)])
# }
# NOT RUN {
##
## spline example
##
splineHelp <- findFn("spline", maxPages = 2)
splinePkgs <- packageSum(splineHelp)
# }
Run the code above in your browser using DataLab