Getting Help
R includes a help system to help you get information about
installed packages. To get help on a function, for example, glm
you would type:
> help(glm)
or, equivalently:
> ?glm
To search for help on an operator, you need to place the operator in backquotes:
> ?`+`
If you’d like to try the examples in a help file, you can use
the example
function to
automatically try them. For example, to see the example for glm
, type:
> example(glm)
You can search for help on a topic, for example, “regression,”
using the help.search
function:
> help.search("regression")
This can be very helpful if you can’t remember the name of a function; R will return a list of relevant topics. There is a shorthand for this command as well:
> ??regression
To get the help file for a package, you can sometimes use one of
the commands above. However, you can also use the help
option for the
library
command to get more
complete information. For example, to get help on the grDevices
library, you would use the
following function:
> library(help="grDevices")
Some packages (especially packages from Bioconductor) include at least one vignette. A
vignette is a short document that
describes how to use the package, complete with examples. You can view
a vignette using the vignette
command. For example, to view the vignette for the affy
package (assuming that you have
installed this package), you would use the following command:
> vignette("affy")
To view available vignettes for all attached packages, you can use the following ...
Get R in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.