PackageSum2: Add Info from Installed Packages to PackageSummary

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/PackageSum2.R

Description

Add information on installed packages to the PackageSummary of an RSiteSearch object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
PackageSum2(x,
        fields=c("Title", "Version", "Author", "Maintainer", "Packaged"),
            lib.loc=NULL, ...)
## S3 method for class 'RSiteSearch'
PackageSum2(x,
        fields=c("Title", "Version", "Author", "Maintainer", "Packaged"),
            lib.loc=NULL, ...)
## S3 method for class 'data.frame'
PackageSum2(x,
        fields=c("Title", "Version", "Author", "Maintainer", "Packaged"),
            lib.loc=NULL, ...)
## S3 method for class 'list'
PackageSum2(x,
        fields=c("Title", "Version", "Author", "Maintainer", "Packaged"),
            lib.loc=NULL, ...)

Arguments

x

a data.frame with columns Package and Score.

fields

character vector of names to look for in components of packageDescription(x$Package[i]) and return as additional columns of x if found.

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)

Details

With an object of class RSiteSearch, 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 RSiteSearch object, add other columns from attributes of packageDescription for installed packages named in the column Package.

Value

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

Author(s)

Spencer Graves

See Also

RSiteSearch.function PackageSummary

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
##
## data.frame method
##
tstdf <- data.frame(Package=c('fda', 'base'), stringsAsFactors=FALSE)
tst2 <- PackageSum2(tstdf)

##
## list method
##
tstList <- list(PackageSummary=tstdf)

all.equal(tst2, PackageSum2(tstList))


##
## RSiteSearch method
##
tstRSearch <- data.frame(Package=c('fda', 'base')[c(1,1,2)], Score=2:4,
                    Date=LETTERS[1:3], stringsAsFactors=FALSE)
attr(tstRSearch, 'PackageSummary') <- PackageSummary(tstRSearch)
class(tstRSearch) <- c('RSiteSearch', 'data.frame')
tst2. <- PackageSum2(tstRSearch)

# row names are different from tst2, so fix ...
row.names(tst2.) <- row.names(tst2)

all.equal(tst2, tst2.[names(tst2)])

RSiteSearch documentation built on May 31, 2017, 3:47 a.m.