.BG
.VE $Header: /usr3/s/current/s/.help/RCS/sapply,v 1.2 83/12/30 19:34:03 rab Exp $
.FN sapply
.TL
sapply: Apply a Function to Components of a Structure
.CS
sapply(x, fun, max=, arg1, arg2, ...)
.PP
.AG x
hierarchical structure.  An arbitrary S function will be
applied to each component of `x', and the result will become
the corresponding component of the result of `sapply'.
Missing values (NAs) are allowed if `fun' accepts them.
.AG fun
character string giving the name of the function.
.AG max=
optional argument (only in the `name=expression' form)
giving the maximum size for the result of any single
application of the function.  For example, if `fun' returned
a result the same size as its argument, the maximum size of
the components of `x' is the relevant number.  Default 1000.
.AG argi
other arguments to `fun', if any.
.RT
structure whose first component is the result of `fun'
applied to the first component of `x', etc.  If all the
results are the same length, `sapply' returns a matrix with
one column for each component.  If all the results are
scalars, a vector is returned.
.EX
sapply(x,"mean") #vector of means of components of x
sapply(x,"sort") # sort the components
.SH SEE ALSO
Function `apply' can be used to perform similar operations
on the sections of a matrix or array, and `tapply' operates on
data classified by categorical variables.
.KW basic*
.KW apply*
.KW structure
.WR
