\Header{rle}{Run Length Encoding}
\keyword{manip}{rle}
\begin{Description}\relax
Compute the lengths and values of runs of equal values in a vector.\end{Description}
\begin{Usage}
\begin{verbatim}
rle(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a (numerical, logical or character) vector.
\end{ldescription}
\end{Arguments}
\begin{Value}
A list with components
\begin{ldescription}
\item[\code{lengths}] a vector containing the length of each run.
\item[\code{values}] a vector of the same length as \code{lengths} with the
corresponding values.
\end{ldescription}
\end{Value}
\begin{Examples}
\begin{ExampleCode}
x <- rev(rep(6:10, 1:5))
rle(x)
## $lengths
## [1] 5 4 3 2 1
## $values
## [1] 10  9  8  7  6
z <- c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE)
rle(z)
rle(as.character(z))
\end{ExampleCode}
\end{Examples}

