\HeaderA{endoapply}{Endomorphisms via application of a function over an object's elements}{endoapply}
\aliasA{endoapply,data.frame-method}{endoapply}{endoapply,data.frame.Rdash.method}
\aliasA{endoapply,list-method}{endoapply}{endoapply,list.Rdash.method}
\aliasA{mendoapply}{endoapply}{mendoapply}
\aliasA{mendoapply,data.frame-method}{endoapply}{mendoapply,data.frame.Rdash.method}
\aliasA{mendoapply,list-method}{endoapply}{mendoapply,list.Rdash.method}
\keyword{manip}{endoapply}
\keyword{utilities}{endoapply}
\begin{Description}\relax
Performs the endomorphic equivalents of
\code{\LinkA{lapply}{lapply}} and \code{\LinkA{mapply}{mapply}} by returning
objects of the same class as the inputs rather than a list.
\end{Description}
\begin{Usage}
\begin{verbatim}
  endoapply(X, FUN, ...)

  mendoapply(FUN, ..., MoreArgs = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] a list, data.frame or Sequence object.
\item[\code{FUN}] the function to be applied to each element of \code{X}
(for \code{endoapply}) or for the elements in \code{...}
(for \code{mendoapply}).
\item[\code{...}] For \code{endoapply}, optional arguments to \code{FUN}.
For \code{mendoapply}, a set of list, data.frame or Sequence
objects to compute over.
\item[\code{MoreArgs}] a list of other arguments to \code{FUN}.
\end{ldescription}
\end{Arguments}
\begin{Value}
\code{endoapply} returns an object of the same class as \code{X},
each element of which is the result of applying \code{FUN} to the
corresponding element of \code{X}.

\code{mendoapply} returns an object of the same class as the first
object specified in \code{...}, each element of which is the result
of applying \code{FUN} to the corresponding elements of \code{...}.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{lapply}{lapply}}, \code{\LinkA{mapply}{mapply}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  a <- data.frame(x = 1:10, y = rnorm(10))
  b <- data.frame(x = 1:10, y = rnorm(10))

  endoapply(a, function(x) (x - mean(x))/sd(x))
  mendoapply(function(e1, e2) (e1 - mean(e1)) * (e2 - mean(e2)), a, b)
\end{ExampleCode}
\end{Examples}

