Learn R Programming

sos (version 2.1-8)

PackageSum2: Add Info from Installed Packages to PackageSummary

Description

Add information on installed packages to the PackageSummary of a findFn object.

Usage

PackageSum2(x,
    fields=c("Title", "Version", "Author", "Maintainer", 
      "Packaged", 'helpPages', 'vignette', 'URL'), 
        lib.loc=NULL, ...)
# S3 method for findFn
PackageSum2(x,
    fields=c("Title", "Version", "Author", "Maintainer",
      "Packaged", 'helpPages', 'vignette', 'URL'), 
        lib.loc=NULL, ...)
# S3 method for data.frame
PackageSum2(x,
    fields=c("Title", "Version", "Author", "Maintainer",
      "Packaged", 'helpPages', 'vignette', 'URL'), 
        lib.loc=NULL, ...)
# S3 method for list
PackageSum2(x,
    fields=c("Title", "Version", "Author", "Maintainer",
      "Packaged", 'helpPages', 'vignette', 'URL'), 
        lib.loc=NULL, ...)

Value

a data.frame with additional fields columns appended to a PackageSummary

data.frame.

Arguments

x

a data.frame with columns Package and Score.

fields

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.

lib.loc

an optional lib.loc argument passed to packageDescription.

...

additional arguments (currently unused)

Author

Spencer Graves

Details

With an object of class findFn, extract the PackageSummary attribute and pass it to the data.frame method.

With an object of class list, extract the PackageSummary component and pass it to the data.frame method.

For a data.frame that is not an findFn object, add other columns from attributes of packageDescription for installed packages named in the column Package. Also, for any packages that are installed, replace the Date with the Packaged date. The Date in Baron's RSiteSearch database is the date of acquisition, which will typically be more recent than the Packaged date provided the locally installed package has the same version as that in Baron's database. To get the best information from PackageSum2, it is wise to first run both installPackages to ensure that the packages of greatest interest are installed locally and update.packages() to make sure you have the latest versions installed locally. Similarly, if PackageSum2 does not contain complete interest on a package of interest, this can be fixed by installing the package and rerunning PackageSum2.

See Also

packageSum, which does essentially the same thing but returns an object of class packageSum. findFn PackageSummary installPackages

Examples

Run this code
##
## data.frame method
##
Tstdf <- data.frame(Package=c('grid', 'base'), 
            stringsAsFactors=FALSE)
Tst2 <- PackageSum2(Tstdf)

##
## list method
##
TstList <- list(PackageSummary=Tstdf)
stopifnot(
all.equal(Tst2, PackageSum2(TstList))
)

##
## 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. <- PackageSum2(Tst.findFn)

stopifnot(
all.equal(Tst2, Tst2.[names(Tst2)])
)

Run the code above in your browser using DataLab