\HeaderA{extendrange}{Extend a Numerical Range by a Small Percentage}{extendrange}
\keyword{dplot}{extendrange}
\begin{Description}\relax
Extends a numerical range by a small percentage, i.e., fraction,
\emph{on both sides}.
\end{Description}
\begin{Usage}
\begin{verbatim}
extendrange(x, r = range(x, na.rm = TRUE), f = 0.05)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] numeric vector; not used if \code{r} is specified.
\item[\code{r}] numeric vector of length 2; defaults to the
\code{\LinkA{range}{range}} of \code{x}.
\item[\code{f}] number specifying the fraction by which the range should be
extended.
\end{ldescription}
\end{Arguments}
\begin{Value}
A numeric vector of length 2, \code{r + c(-f,f) * diff(r)}.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{range}{range}}; \code{\LinkA{pretty}{pretty}} which can be
considered a sophisticated extension of \code{extendrange}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- 1:5
(r <- range(x))         # 1    5
extendrange(x)          # 0.8  5.2
extendrange(x, f= 0.01) # 0.96 5.04
## Use 'r' if you have it already:
stopifnot(identical(extendrange(r=r),
                    extendrange(x)))
\end{ExampleCode}
\end{Examples}

