sos (version 2.0-0)

findFn: Search Help Pages


Returns a data.frame from RSiteSearch(string, "function") which can be sorted and subsetted by user specifications and viewed in an HTML table. The default sort puts first packages with the most matches (Count), with ties broken using the sum of the match scores for all the hits in that package (TotalScore), etc.


findFn(string, maxPages = 20, sortby = NULL, verbose = 1, ...)




A character string. See RSiteSearch.


The maximum number of pages to download assuming 20 links per page.


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


an integer: if 0, no output is printed to the console. The default 1 displays an initial line with the number of pages to be retrieved and the number of matches obtained; if the number of matches to be downloaded is less, this also is displayed on the initial line. This is followed by a second line counting the pages downloaded.

If greater than 1, additional information is provided on the download process.



an object of class c('findFn', 'data.frame') with columns and attributes as follows:


  • Count Total number of matches downloaded in this package

  • MaxScore maximum of the Score over all help pages selected within each Package. See Score below or the Namazu website (link below) for more information on how the score is determined.

  • TotalScore sum of the Score over all help pages selected within each Package. See Score below or the Namazu website (link below) for more information on how the score is determined.

  • Package Name of the package containing a help page meeting the search criteria

  • Function Name of the help page found that meets the indicated search criterion.

  • Date Date of the help page

  • Score Score returned by RSiteSearch, discussed in the Namazu website (link below).

  • Description Title of the help page

  • Link Universal Resource Locator (URL) for the help page


  • matches an integer = total number of matches found by the search. This typically will exceed the number of rows found, because the search algorithm sometimes finds things that are not help pages for packages.

  • PackageSummary a data.frame with one row for each package and columns Package, Count, MaxScore, TotalScore, and Date, sorted as in the sort. argument.

  • string the string argument in the call.

  • callthe matched call


findFn searchs the help pages of packages covered by the RSiteSearch archives. To restrict the search to only packages installed locally, use

1. Access the RSitSearch engine with string, restricting to "functions", storing Score, Package, Function, Date, Description, and Link in a data.frame.

2. Compute Count, MaxScore and TotalScore for each Package accessed. Combine them in a matrix PackageSummary.

3. Sort PackageSummary in the order defined by the occurrance of c('Count', 'MaxScore', 'TotalScore', 'Package') in sortby.

4. Merge PackageSummary with the data.frame of search matches.

5. Sort the combined data.frame as defined by sort..

6. Make the result have class c("findFn", "data.frame") and add attributes matches, PackageSummary, string, and call.

7. Done.

References - reference on determining Score

See Also to search only installed packages. RSiteSearch, download.file for a web interface to this same search capability with more general options. findFn searches only "Target: Functions" from that site, ignoring the R-help arcihves. for a list of alternative R search capabilities, each of which may be best for different types of inquiries.

findFunction for a completely different function with a similar name.


Run this code
# Skip these tests on CRAN,
# because they take more than 5 seconds

z <- findFn("spline", maxPages = 2)
# alternative
zq <- ???spline(2)

# }
all.equal(z, zq)
# }
# To search for 2 terms, not necessarily together:
RSS <- findFn('RSiteSearch function', 1)

# To search for an exact string, use braces:
RSS. <- findFn('{RSiteSearch function}', 1)
matches(RSS.) # list(nrow = 0, matches = 0)

# example in which resulting page has some unicode characters
Lambert <- findFn("Lambert")
## Too many matches
fa <- findFn('factor analysis')
# Finds too many matches to process;
# reports Inf matches but returns none.
# When this happens, use a more restrictive search

# check
fa0 <- RSS.[seq(1, length=0),]
attr(fa0, 'matches') <- Inf
attr(fa0, 'PackageSummary') <- PackageSummary(fa0)
attr(fa0, 'string') <- 'factor+analysis'
attr(fa0, 'call') <- call('findFn', string = "factor analysis")

# }
all.equal(fa, fa0)
# }
# }

Run the code above in your browser using DataCamp Workspace