help {utils} | R Documentation |
help
is the primary interface to the help systems.
help(topic, package = NULL, lib.loc = NULL, verbose = getOption("verbose"), try.all.packages = getOption("help.try.all.packages"), help_type = getOption("help_type"))
topic |
usually, a name or character string specifying the
topic for which help is sought. A character string (enclosed in
explicit single or double quotes) is always taken as naming a topic.
If the value of See ‘Details’ for what happens if this is omitted. |
package |
a name or character vector giving the packages to look
into for documentation, or NULL . By default, all packages in
the search path are used. To avoid a name being deparsed use e.g.
(pkg_ref) . |
lib.loc |
a character vector of directory names of R libraries,
or NULL . The default value of NULL corresponds to all
libraries currently known. If the default is used, the loaded
packages are searched before the libraries. |
verbose |
logical; if TRUE , the file name is reported. |
try.all.packages |
logical; see Note . |
help_type |
character string: the type of help required.
Possible values are "text" , "html" ,
"postscript" , "ps" and "pdf" . Case is ignored,
and partial matching is allowed. |
The following types of help are available:
browseURL
.
(Where possible an existing browser window is re-used: the Mac OS X
GUI uses its own browser window.)
If for some reason HTML help is unavailable (see
startDynamicHelp
), plain text help will be used
instead.
help
only, typeset as a PostScript or PDF file –
see the section on ‘Offline help’.
With packages installed under R 2.10.0 or later help pages are generated when needed from parsed Rd files. Packages installed under earlier versions of R do not have parsed Rd files, but do (by default) have prebuilt text, html and latex help pages, and these are used if parsed Rd files are not available.
The rendering of text help will use directional quotes in suitable
locales (UTF-8 and single-byte Windows locales): sometimes the fonts
used do not support these quotes so this can be turned off by setting
options(useFancyQuotes = FALSE)
.
topic
is not optional: if it is omitted R will give (text)
information on the package (including hints to suitable help topics)
if a package is specified, a (text) list of available packages if
lib.loc
only is specified, and help on help
itself if
none of the first three arguments is specified.
Some topics need to be quoted (by backticks) or given as a
character string. There include those which cannot syntactically
appear on their own such as unary and binary operators,
function
and control-flow reserved words (including
if
, else
for
, in
, repeat
,
while
, break
and next
. The other reserved
words can be used as if they were names, for example TRUE
,
NA
and Inf
.
If multiple help files matching topic
are found, in interactive
use a menu is presented for the user to choose one: in batch use the
first on the search path is used. (For HTML help the menu will be an
HTML page, otherwise a graphical menu if possible if
getOption("menu.graphics")
is true, the default.)
Typeset documentation is produced by running the LaTeX version of the
help page through latex
and dvips
or, if
help_type = "PDF"
, pdflatex
. This will either
produce a PostScript or PDF file or (depending on the configuration of
dvips
) send a PostScript file to a printer.
The appearance of the output can be customized through a file
‘Rhelp.cfg’ somewhere in your LaTeX search path: this will be
input as a LaTeX style file after Rd.sty
. Some
environment variables are consulted, notably R_PAPERSIZE
(via getOption("papersize")
) and R_RD4DVI /
R_RD4PDF (see ‘Making manuals’ in the
‘R Installation and Administration Manual’).
If there is a function offline_help_helper
in the workspace or
further down the search path it is used to do the typesetting,
otherwise the function of that name in the utils
name space
(to which the first paragraph applies). It should have two
arguments, the name of the LaTeX file to be typeset and the type.
Unless lib.loc
is specified explicitly, the loaded packages are
searched before those in the specified libraries. This ensures that
if a library is loaded from a library not in the known library trees,
then the help from the loaded library is used. If lib.loc
is
specified explicitly, the loaded packages are not searched.
If this search fails and argument try.all.packages
is
TRUE
and neither packages
nor lib.loc
is
specified, then all the packages in the known library trees are
searched for help on topic
and a list of (any) packages where
help may be found is displayed (with hyperlinks for help_type =
"html"
). NB: searching all packages can be slow, especially
the first time (caching of files by the OS can expedite subsequent
searches dramatically).
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
?
for shortcuts to help topics.
help.search()
or ??
for finding help pages
on a vague topic;
help.start()
which opens the HTML version of the R
help pages;
library()
for listing available packages and the
help objects they contain;
data()
for listing available data sets;
methods()
.
Use prompt()
to get a prototype for writing help
pages of your own package.
help() help(help) # the same help(lapply) help("for") # or ?"for", but quotes/backticks are needed help(package="splines") # get help even when package is not loaded topi <- "women" help(topi) try(help("bs", try.all.packages=FALSE)) # reports not found (an error) help("bs", try.all.packages=TRUE) # reports can be found # in package 'splines'