
Last chance! 50% off unlimited learning
Sale ends in
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"))
If the value of topic
is a length-one
character vector the topic is taken to be the value of the only
element. Otherwise topic
must be a name or a reserved
word (if syntactically valid) or character string.
See ‘Details’ for what happens if this is omitted.
NULL
. By default, all packages
whose namespaces are loaded are used. To avoid a name being deparsed use e.g.
(pkg_ref)
(see the examples).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. This is not used for
HTML help (see ‘Details’.TRUE
, the file name is reported.Note
."text"
, "html"
and "pdf"
.
Case is ignored, and partial matching is allowed.pdflatex
: this will produce a PDF file. 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_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
namespace (to
which the first paragraph applies). It should accept at least two
arguments, the name of the LaTeX file to be typeset and the type
(which is nowadays ignored). It accepts a third argument,
texinputs
, which will give the graphics path when the help
document contains figures, and will otherwise not be supplied.browseURL
.
unix
(Where possible an existing browser window is re-used: the 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 PDF --
see the section on ‘Offline help’.
unix The ‘factory-fresh’ default is text help except from the OS X GUI, which uses HTML help displayed in its own browser window. windows The default for the type of help is selected when R is installed -- the ‘factory-fresh’ default is HTML help.
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
lib.loc
only is specified, a (text) list of available
packages.
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. These 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.)
Note that HTML help does not make use of lib.loc
: it will
always look first in the loaded packages and then along
.libPaths()
.
?
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
try({# requires working TeX installation:
help(dgamma, help_type = "pdf")
## -> nicely formatted pdf -- including math formula -- for help(dgamma):
system2(getOption("pdfviewer"), "dgamma.pdf", wait = FALSE)
})
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'
## For programmatic use:
topic <- "family"; pkg_ref <- "stats"
help((topic), (pkg_ref))
Run the code above in your browser using DataLab