PackageSummary: Summarize findFn Results by Package

View source: R/PackageSummary.R

PackageSummaryR Documentation

Summarize findFn Results by Package

Description

Returns a data.frame with one row for each package and columns Count = number of rows in the search results for that package, maxScore and totalScore = max and total score for help pages found from that package.

Usage

PackageSummary(x, sortby=NULL)

Arguments

x

a data.frame with columns Package, Score, and Date.

sortby

a character vector specifying how the data.frame returned should be sorted. Default = c('Count', 'MaxScore', 'TotalScore', 'Package') to sort descending on numerics and ascending on alphanumerics. Specifying sortby = c('c', 't', 'm') is equivalent to c('Count', 'TotalScore', 'MaxScore', 'Package').

Components of sortby must match either this list or c('Score', 'Function', 'Date', 'Description', 'Link'). Any on this latter list are ignored without a warning. This allows the same sortby used for findFn to be used here.

Details

1. Convert x['Package'] to character to automatically drop any unused levels of a factor.

2. Compute Count, TotalScore, and MaxScore.

3. Find the first occurrence of each Package, and use that to convert the Link to the first help page to pkgLink = a link for the package. For example, the Link to 'html' for help('c') is 'http://finzi.psych.upenn.edu/R/library/base/html/c.html', and pkgLink to the 'html' overview for 'base' is 'http://finzi.psych.upenn.edu/R/library/base/html/00Index.html'.

4. Assemble into a data.frame, sort and return.

Value

a data.frame with one row for each package and columns Package, Count, MaxScore, TotalScore, Date, and pkgLink, sorted as specified by sortby.

Author(s)

Spencer Graves

See Also

RSiteSearch, findFn PackageSum2, packageSum

Examples

tstdf <- data.frame(Package=letters[c(1,1,2)], Score=2:4,
                    Date=LETTERS[1:3], stringsAsFactors=FALSE)
tstdf$Link <- paste0('http://finzi.psych.upenn.edu/R/library/', 
    tstdf$Package, '/html/', letters[4:6], '.html')
    
tstSum <- PackageSummary(tstdf)
# The answer:
tstSm <- data.frame(Package=letters[1:2], Count=c(a=2, b=1),
    MaxScore=c(3, 4), TotalScore=c(5, 4), 
    Date=LETTERS[c(1, 3)], stringsAsFactors=FALSE)
tstSm$pkgLink <- paste0('http://finzi.psych.upenn.edu/R/library/', 
    tstdf$Package[2:3], '/html/00Index.html')    
row.names(tstSm) <- 1:2

all.equal(tstSum, tstSm)


sos documentation built on June 30, 2024, 1:06 a.m.