\HeaderA{runstat}{Fixed width running window summaries across vector-like objects}{runstat}
\aliasA{runmean}{runstat}{runmean}
\aliasA{runq}{runstat}{runq}
\aliasA{runsum}{runstat}{runsum}
\aliasA{runwtsum}{runstat}{runwtsum}
\keyword{methods}{runstat}
\keyword{algebra}{runstat}
\keyword{arith}{runstat}
\begin{Description}\relax
The \code{runsum}, \code{runmean}, \code{runwtsum}, \code{runq} functions
calculate the sum, mean, weighted sum, and order statistics for fixed width
running windows.
\end{Description}
\begin{Usage}
\begin{verbatim}
  runsum(x, k, endrule = c("drop", "constant"))
  runmean(x, k, endrule = c("drop", "constant"))
  runwtsum(x, k, wt, endrule = c("drop", "constant"))
  runq(x, k, i, endrule = c("drop", "constant"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] The data object.

\item[\code{k}] An integer indicating the fixed width of the running window. Must be
odd when \code{endrule == "constant"}.

\item[\code{wt}] A numeric vector of length \code{k} that provides the weights to use.

\item[\code{i}] An integer indicating which order statistic to calculate.

\item[\code{endrule}] A character string indicating how the values at the beginning
and the end (of the data) should be treated.
\describe{
\item[\code{"drop"}] do not extend the running statistics to
be the same length as the underlying vectors;
\item[\code{"constant"}] copies running statistic to the
first values and analogously for the last ones making the
smoothed ends \emph{constant};
}

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{runsum}, \code{runmean}, \code{runwtsum}, and \code{runq}
functions provide efficient methods for calculating the specified
numeric summary by performing the looping in compiled code.
\end{Details}
\begin{Value}
An object of the same class as \code{x}.
\end{Value}
\begin{Author}\relax
P. Aboyoun
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{runmed}{runmed}}, \LinkA{Rle-class}{Rle.Rdash.class}, \LinkA{RleList-class}{RleList.Rdash.class}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  x <- Rle(1:10, 1:10)
  runsum(x, k = 3)
  runsum(x, k = 3, endrule = "constant")
  runmean(x, k = 3)
  runwtsum(x, k = 3, wt = c(0.25, 0.5, 0.25))
  runq(x, k = 5, i = 3, endrule = "constant")
\end{ExampleCode}
\end{Examples}

