These functions provide access to documentation.
Documentation on a topic with name
name (typically, an R
object or a data set) can be displayed by either
1 2 3
Usually, a name or character string specifying the topic for which help is sought.
Alternatively, a function call to ask for documentation on a
corresponding S4 method: see the section on S4 method documentation.
the special type of documentation to use for this topic;
for example, if the type is
This is a shortcut to
help and uses its default type of help.
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
next. The other
words can be used as if they were names, for example
S4 Method Documentation
Authors of formal (‘S4’) methods can provide documentation
on specific methods, as well as overall documentation on the methods
of a particular function. The
"?" operator allows access to
this documentation in three ways.
methods?f will look for the overall
documentation methods for the function
this means the documentation file containing the alias
There are two different ways to look for documentation on a
particular method. The first is to supply the
in the form of a function call, omitting the
The effect is to look for documentation on the method that would be
used if this function call were actually evaluated. See the examples
below. If the function is not a generic (no S4 methods are defined
for it), the help reverts to documentation on the function name.
"?" operator can also be called with
method; in this case also, the
topic argument is
a function call, but the arguments are now interpreted as specifying
the class of the argument, not the actual expression that will
appear in a real call to the function. See the examples below.
The first approach will be tedious if the actual call involves complicated expressions, and may be slow if the arguments take a long time to evaluate. The second approach avoids these issues, but you do have to know what the classes of the actual arguments will be when they are evaluated.
Both approaches make use of any inherited methods; the signature of
the method to be looked up is found by using
(see the documentation for
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
?? for finding help pages on a vague topic.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
?lapply ?"for" # but quotes/backticks are needed ?`+` ?women # information about data set "women" ## Not run: require(methods) ## define a S4 generic function and some methods combo <- 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 documentation methods?combo # looks for the overall methods documentation method?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 ## End(Not run)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.