\Header{Extremes}{Maxima and Minima}
\alias{max}{Extremes}
\alias{min}{Extremes}
\alias{pmax}{Extremes}
\alias{pmin}{Extremes}
\keyword{univar}{Extremes}
\keyword{arith}{Extremes}
\begin{Description}\relax
Returns the (parallel) maxima and minima of the input values.\end{Description}
\begin{Usage}
\begin{verbatim}
max(..., na.rm=FALSE)
min(..., na.rm=FALSE)

pmax(..., na.rm=FALSE)
pmin(..., na.rm=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] numeric arguments.
\item[\code{na.rm}] a logical indicating whether missing values should be
removed.
\end{ldescription}
\end{Arguments}
\begin{Value}
\code{max} and \code{min} return the maximum or minimum of all the
values present in their arguments, as \code{\Link{integer}} if all are
\code{integer}, 
or as \code{\Link{double}} otherwise.

The minimum and maximum of an empty set are \code{+Inf} and \code{-Inf}
(in this order!) which ensures \emph{transitivity}, e.g.,
\code{min(x1, min(x2)) == min(x1,x2)}.
In \R{} versions before 1.5, \code{min(integer(0)) == .Machine\$integer.max},
and analogously for \code{max}, preserving argument \emph{type},
whereas from \R{} version 1.5.0, \code{max(x) == -Inf} and
\code{min(x) == +Inf} whenever \code{length(x) == 0} (after removing
missing values if requested).

If \code{na.rm} is \code{FALSE} an \code{NA} value in any of the
arguments will cause a value of \code{NA} to be returned, otherwise
\code{NA} values are ignored.

\code{pmax} and \code{pmin} take several vectors as arguments and
return a single vector giving the parallel maxima (or minima) of the
vectors.  The first element of the result is the maximum (minimum) of
the first elements of all the arguments, the second element of the
result is the maximum (minimum) of the second elements of all the
arguments and so on.  Shorter vectors are recycled if necessary.  If
\code{na.rm} is \code{FALSE}, \code{NA} values in the input vectors
will produce \code{NA} values in the output.  If \code{na.rm} is
\code{TRUE}, \code{NA} values are ignored.
\code{\Link{attributes}} (such as \code{\Link{names}} or
\code{\Link{dim}}) are transferred from the first argument (if applicable).\end{Value}
\begin{SeeAlso}\relax
\code{\Link{range}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
min(5:1,pi)
pmin(5:1, pi)
x <- sort(rnorm(100));  cH <- 1.35
pmin(cH, quantile(x)) # no names
pmin(quantile(x), cH) # has names
plot(x, pmin(cH, pmax(-cH, x)), type='b', main= "Huber's function")
\end{ExampleCode}
\end{Examples}

