Information Technology Reference
In-Depth Information
This will either open a window with function documentation or display the documen-
tation on your console, depending on your platform. A shortcut for the help command
is to simply type ? , followed by the function name:
> ?mean
Sometimes you just want a quick reminder of the arguments to a function; what are
they, and in what order do they occur? Use the args function:
> args(mean)
function (x, ...)
NULL
> args(sd)
function (x, na.rm = FALSE)
NULL
The first line of output from args is a synopsis of the function call. For mean , the synopsis
shows one argument, x , which is a vector of numbers. For sd , the synopsis shows the
same vector, x , and an optional argument called na.rm . (You can ignore the second line
of output, which is often just NULL .)
Most documentation for functions includes examples near the end. A cool feature of
R is that you can request that it execute the examples, giving you a little demonstration
of the function's capabilities. The documentation for the mean function, for instance,
contains examples, but you don't need to type them yourself. Just use the example
function to watch them run:
> example(mean)
mean> x <- c(0:10, 50)
mean> xm <- mean(x)
mean> c(xm, mean(x, trim = 0.1))
[1] 8.75 5.50
mean> mean(USArrests, trim = 0.2)
Murder Assault UrbanPop Rape
7.42 167.60 66.20 20.16
The user typed example(mean) . Everything else was produced by R, which executed the
examples from the help page and displayed the results.
1.3 Viewing the Supplied Documentation
Problem
You want to read the documentation supplied with R.
 
Search WWH ::




Custom Search