Contents
 |
Introduction
To R |
Help!
R has an online help system. Start it up with the function:
> help.start()
This will either start netscape, or if netscape is already running, start
the help system in a netscape window.
Clicking on packages pops up a window with a list of
all packages. Click on a package to get a list of all individual functions
within that package along with a brief description of each one. Clicking
on a function name pops up a window with the documentation for that function.
This takes the form of a formatted text page with several sections. Most
function help pages will have the first few sections - DESCRIPTION, USAGE,
ARGUMENTS and VALUE:
-
DESCRIPTION : a short summary of the function in one or two lines.
-
USAGE : a listing of the function with all its arguments. From this
you can also determine the default of any missing arguments. For example,
the USAGE section for the rnorm() function looks like this:
rnorm(n, mean=0, sd=1)
this tells us that the parameters are in order n,mean,sd and that
the defaults for mean and sd are 0 and 1.
ARGUMENTS : this describes the function of each argument in turn.
For rnorm() it tells us that n is a required argument
giving the number of random numbers to return.
VALUE : this details the return value of the function - in the case
of rnorm() we are told it returns a random sample for the normal
distribution with the given parameters.
In fact the help page for rnorm() is slightly complicated by the
fact that it is interleaved with the help for pnorm(),
dnorm()
and qnorm(). Often you will find the help for several closely-related
functions in the same file.
Other Sections
The help file for a function may also contain other sections giving more
detail of the algorithm used, references, some examples of how to use the
function, and a list of related functions in a SEE ALSO section.
Quick Help
If you know the name of a function you want help on then you can just type
help(function_name)
or simply
?function_name. For example:
> ?rnorm
If you have done help.start() then the help file will pop up otherwise
it will be shown within your R session or at another window of emacs if
running R within it.
Topic searching
You can enter a word in the Search box of the help window
Search
Engine & Keywords and it will search the function descriptions
for that keyword.
Quick Argument Lists
If you've forgotten exactly what arguments a function uses, then the
args()
function will spit them out for you:
> args(rnorm)
function(n, mean = 0, sd = 1)
NULL
Ignoring the NULL, this quickly tells us the names and defaults
of the arguments, which can be very useful.
Contents