Rev 26673 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{help}\alias{help}\alias{?}\alias{topicName} % internal\alias{.helpForCall} % internal\alias{.tryHelp} % internal\title{Documentation}\description{These functions provide access to documentation.Documentation on a topic with name \code{name} (typically, an \Robject or a data set) can be printed with either \code{help(name)} or\code{?name}.}\usage{help(topic, offline = FALSE, package = .packages(),lib.loc = NULL, verbose = getOption("verbose"),try.all.packages = getOption("help.try.all.packages"),#ifdef unixhtmlhelp = getOption("htmlhelp"),#endif#ifdef windowschmhelp = getOption("chmhelp"),htmlhelp = getOption("htmlhelp"), winhelp = getOption("winhelp"),#endifpager = getOption("pager"))?topictype?topic}\arguments{\item{topic}{usually, the name on which documentation is sought.The name may be quoted or unquoted (but note that if \code{topic}is the name of avariable containing a character string documentation is provided forthe name, not for the character string).The \code{topic} argument may also be a function call, to ask fordocumentation on a corresponding method. See the section on methoddocumentation.}\item{offline}{a logical indicating whether documentation should bedisplayed on-line to the screen (the default) or hardcopy of itshould be produced.}\item{package}{a name or character vector giving the packages to lookinto for documentation. By default, all packages in the search pathare used.}\item{lib.loc}{a character vector of directory names of \R libraries,or \code{NULL}. The default value of \code{NULL} corresponds to alllibraries currently known. If the default is used, the loadedpackages are searched before the libraries.}\item{verbose}{logical; if \code{TRUE}, the file name is reported.}\item{try.all.packages}{logical; see \code{Notes}.}#ifdef unix\item{htmlhelp}{logical (or \code{NULL}). If \code{TRUE} (which is thedefault after \code{\link{help.start}} has been called), the HTMLversion of the help will be shown in the browser specified by\code{options("browser")}. See \code{\link{browseURL}} for detailsof the browsers that are supported. Where possible an existingbrowser window is re-used.}#endif#ifdef windows\item{chmhelp}{logical (or \code{NULL}). If \code{TRUE} theCompiled HTML version of the help will be shown in a help viewer.}\item{htmlhelp}{logical (or \code{NULL}). If \code{TRUE}, the HTMLversion of the help will be shown in a browser specified by\code{options("browser")} or the file-association mechanism.}\item{winhelp}{logical (or \code{NULL}). If \code{TRUE}, a Windows\code{.hlp} file will be used if one is available.}#endif\item{pager}{the pager to be used for \code{\link{file.show}}.}\item{type}{the special type of documentation to use for this topic;for example, if the type is \code{class}, documentation isprovided for the class with name \code{topic}. The function\code{topicName} returns the actual name used in this case.See the section on method documentation for the uses of\code{type} to get help on formal methods.}}\details{In the case of unary and binary operators and control-flow specialforms (including \code{if}, \code{for} and \code{function}), the topicmay need to be quoted.#ifdef unixIf \code{offline} is \code{TRUE}, hardcopy of the documentation isproduced by running the LaTeX version of the help page through\code{latex} (note that LaTeX 2e is needed) and \code{dvips}.Depending on your \code{dvips} configuration, hardcopy will be sent tothe printer or saved in a file. If the programs are in non-standardlocations and hence were not found at compile time, you can either setthe options \code{latexcmd} and \code{dvipscmd}, or the environmentvariables \env{R\_LATEXCMD} and \env{R\_DVIPSCMD} appropriately.The appearance of the output can be customized through a file\file{Rhelp.cfg} somewhere in your LaTeX search path.#endif#ifdef windowsIf \code{offline} is \code{TRUE}, hardcopy of the documentation isproduced by running the LaTeX version of the help page through\code{latex} (note that LaTeX 2e is needed). You need to customizethe file \file{R\_HOME/bin/helpPRINT.bat} which contains an example.The appearance of the output can be customized through a file\file{Rhelp.cfg} somewhere in your LaTeX search path.#endif}\note{Unless \code{lib.loc} is specified explicitly, the loaded packages aresearched before those in the specified libraries. This ensures thatif a library is loaded from a library not in the known library trees,then the help from the loaded library is used. If \code{lib.loc} isspecified explicitly, the loaded packages are \emph{not} searched.If this search fails and argument \code{try.all.packages} is\code{TRUE} and neither \code{packages} nor \code{lib.loc} isspecified, then all the packages in the known library trees aresearched for help on \code{topic} and a list of (any) packages wherehelp may be found is printed (but no help is shown).\bold{N.B.} searching all packages can be slow.The help files can be many small files. On some file systems it isdesirable to save space, and the text files in the \file{help} directoryof an installed package can be zipped up as a zip archive\file{Rhelp.zip}. Ensure that file \file{AnIndex} remains un-zipped.Similarly, all the files in the \file{latex} directory can be zippedto \file{Rhelp.zip}.#ifdef windowsThis is done on Windows for the larger packages.#endif}\section{Method Documentation.}{The authors of formal (\sQuote{S4}) methods can provide documentationon specific methods, as well as overall documentation on the methodsof a particular function. The \code{"?"} operator allows access tothis documentation in three ways.The expression \code{methods ? f} will look for the overalldocumentation methods for the function \code{f}. Currently, thismeans the documentation file containing the alias \code{f-methods}.There are two different ways to look for documentation on aparticular method. The first is to supply the \code{topic} argumentin the form of a function call, omitting the \code{type} argument.The effect is to look for documentation on the method that would beused if this function call were actually evaluated. See the examplesbelow. If the function is not a generic (no S4 methods are definedfor it), the help reverts to documentation on the function name.The \code{"?"} operator can also be called with \code{type} suppliedas \code{"method"}; in this case also, the \code{topic} argument isa function call, but the arguments are now interpreted as specifyingthe class of the argument, not the actual expression that willappear in a real call to the function. See the examples below.The first approach will be tedious if the actual call involvescomplicated expressions, and may be slow if the arguments take along time to evaluate. The second approach avoids thesedifficulties, but you do have to know what the classes of the actualarguments will be when they are evaluated.Both approaches make use of any inherited methods; the signature ofthe method to be looked up is found by using \code{selectMethod}(see the documentation for \code{\link[methods]{getMethod}}).}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\seealso{\code{\link{help.search}()} for finding help pages on a \dQuote{vague}topic;\code{\link{help.start}()} which opens the HTML version of the \Rhelp pages;\code{\link{library}()} for listing available packages and theuser-level objects they contain;\code{\link{data}()} for listing available data sets;\code{\link{methods}()}.See \code{\link{prompt}()} to get a prototype for writing \code{help}pages of private packages.}\examples{help()help(help) # the samehelp(lapply)?lapply # the samehelp("for") # or ?"for", but the quotes are needed?"+"help(package="stepfun") # get help even when package is not loadeddata() # list all available data sets?women # information about data set "women"topi <- "women"\dontrun{help(topi) ##--> Error: No documentation for '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'\dontshow{require(methods)}\dontrun{## define a generic function and some methodscombo <- function(x, y) c(x, y)setGeneric("combo")setMethod("combo", c("numeric", "numeric"),function(x, y) x+y)## assume we have written some documentation for combo, and its methods ....?combo ## produces the function documentationmethods?combo ## looks for the overall methods documentationmethod?combo("numeric", "numeric") ## documentation for the method above?combo(1:10, rnorm(10)) ## ... the same method, selected according to## the arguments (one integer, the other numeric)?combo(1:10, letters) ## documentation for the default method}}\keyword{documentation}