Search the Help System
Allows for searching the help system for documentation matching a given character string in the (file) name, alias, title, concept or keyword entries (or any combination thereof), using either fuzzy matching or regular expression matching. Names and titles of the matched help entries are displayed nicely formatted.
Vignette names, titles and keywords and demo names and titles may also be searched.
help.search(pattern, fields = c("alias", "concept", "title"), apropos, keyword, whatis, ignore.case = TRUE, package = NULL, lib.loc = NULL, help.db = getOption("help.db"), verbose = getOption("verbose"), rebuild = FALSE, agrep = NULL, use_UTF8 = FALSE, types = getOption("help.search.types")) ??pattern field??pattern
- a character string to be matched in the specified
fields. If this is given, the arguments
- a character vector specifying the fields of the help
database to be searched. The entries must be abbreviations of
"keyword", corresponding to the help page's (file) name, its title, the topics and concepts it provides documentation for, and the keywords it can be classified to. See below for how vignettes and demos are searched.
- a character string to be matched in the help page topics and title.
- a character string to be matched in the help page
keywords. Keywords are really categories: the
standard categories are listed in file R.home("doc")/KEYWORDS
(see also the example) and some package writers have defined their
- a character string to be matched in the help page topics.
- a logical. If
TRUE, case is ignored during matching; if
FALSE, pattern matching is case sensitive.
- a character vector with the names of packages to
search through, or
NULLin which case all available packages in the library trees specified by
- a character vector describing the location of R
library trees to search through, or
NULL. The default value of
NULLcorresponds to all libraries currently known.
- a character string giving the file path to a previously
built and saved help database, or
- logical; if
TRUE, the search process is traced. Integer values are also accepted, with
TRUEbeing equivalent to
1being less verbose. On Windows a progress bar is shown during rebuilding, and on Unix a heartbeat is shown for
verbose = 1and a package-by-package list for
verbose >= 2.
- a logical indicating whether the help database should
be rebuilt. This will be done automatically if
lib.locor the search path is changed, or if
packageis used and a value is not found.
NULL(the default unless
keywordis used) and the character string to be matched consists of alphanumeric characters, whitespace or a dash only, approximate (fuzzy) matching via
agrepis used unless the string has fewer than 5 characters; otherwise, it is taken to contain a regular expression to be matched via
FALSE, approximate matching is not used. Otherwise, one can give a numeric or a list specifying the maximal distance for the approximate match, see argument
max.distancein the documentation for
- logical: should be results be given in UTF-8 encoding?
Also changes the meaning of regexps in
agrepto be Perl regexps.
- a character vector listing the types of documentation
to search. The entries must be abbreviations of
"demo". Results will be presented in the order specified.
- a single value of
Upon installation of a package, a pre-built help.search index is serialized as hsearch.rds in the Meta directory (provided the package has any help pages). Vignettes are also indexed in the Meta/vignette.rds file. These files are used to create the help search database.
whatis play a role similar to
the Unix commands with the same names.
agrep = FALSE will be several times faster than
the default (once the database is built). However, approximate
searches should be fast enough (around a second with 5000 packages
If possible, the help database is saved in memory for use by subsequent calls in the session.
Note that currently the aliases in the matching help files are not displayed.
?? the pattern may be prefixed with a
package name followed by
::: to limit the search
to that package.
Vignettes are searched as follows. The
"alias" are both the base of the vignette filename, and the
"concept" entries are taken from the
entries. Vignettes are not classified using the help system
"keyword" classifications. Demos are handled
similarly to vignettes, without the
The results are returned in a list object of class
"hsearch", which has a print method for nicely formatting the results of the query. This mechanism is experimental, and may change in future versions of R.In
R.appon OS X, this will show up a browser with selectable items. On exiting this browser, the help pages for the selected items will be shown in separate help windows.The internal format of the class is undocumented and subject to change.
RSiteSearch to access an on-line search of R resources.
apropos uses regexps and has nice examples.
help.search("linear models") # In case you forgot how to fit linear # models help.search("non-existent topic") ??utils::help # All the topics matching "help" in the utils package help.search("print") # All help pages with topics or title # matching 'print' help.search(apropos = "print") # The same help.search(keyword = "hplot") # All help pages documenting high-level # plots. file.show(file.path(R.home("doc"), "KEYWORDS")) # show all keywords ## Help pages with documented topics starting with 'try'. help.search("\\btry", fields = "alias")