
The arguments that control behaviour are generally optional. You can omit
optional arguments and accept the default values provided by the program. Or you
can supply an argument to override the default.
The usage section of the function’s help page indicates which arguments are
mandatory and which are optional. The optional arguments are those given in the
form: name=value. The ‘‘value’’ is the default that will be used for this argument
if you choose not to provide a value. The default shown in the usage indicates the
type of value that can be passed to the argument, (and further information about
this is given in the argument section below).
Some arguments are shown with defaults that are numerical values. This
indicates for example that you can override the default confidence level of 0.95
used in t.test by passing a different number to the conf.level argument:
[ t:testðx; y; conf:level¼0:99Þ
Some arguments have default values that are either TRUE or FALSE. Arguments
like this are essentially switches that are turned on and off respectively by passing
a ‘‘logical’’ value: TRUE or FALSE. For example the paired t test behaviour can be
switched on by calling the function:
[ t:testðx; y; paired¼TRUEÞ
Some arguments take one of a prescribed set of options. For example the
alternative argument may take either of the three options that are given as a
character vector: c("two.sided", "less", "greater"). The first of these is the
default option. This indicates that you can override the default two-sided alter-
native hypothesis by passing one of the other available options to the alterna-
tive argument:
[ t:testðx; y; alternative¼"less"Þ
Some arguments are shown with a default value of NULL. This indicates that the
argument will not be used unless a value is supplied. In this case there is no clue in
the usage as to what type of value the argument could take, but such information
will normally be given in the arguments and details sections below. For example in
t.test the arguments section indicates that y can take a numeric vector of data
values. If no value is given y is not used, and the function carries out a 1-sample
t test on the sample given as the x argument. Otherwise the function carries out a
2-sample t test on the samples given as the x and y arguments.
Argument names can be abbreviated when this is unambiguous, for example:
alt="less". Arguments are passed to the function as a comma-separated list, and
can be passed in any position within the list provided it is clear which argument is
which. Consequently optional arguments can be passed in any order because they
always have names. Mandatory arguments can be passed as values without names,
but in that case must be passed in their correct positional order relative to any other
mandatory arguments in the argument list.
Functions generally appear within arithmetic expressions, or as arguments to
other functions, or simply as the right side of an assignment. But some functions
8 1 Introduction to R