\HeaderA{Rle-class}{Rle objects}{Rle.Rdash.class}
\aliasA{"!,Rle-method}{Rle-class}{"!,Rle.Rdash.method}
\aliasA{aggregate,Rle-method}{Rle-class}{aggregate,Rle.Rdash.method}
\aliasA{as.character,Rle-method}{Rle-class}{as.character,Rle.Rdash.method}
\aliasA{as.complex,Rle-method}{Rle-class}{as.complex,Rle.Rdash.method}
\aliasA{as.data.frame,Rle-method}{Rle-class}{as.data.frame,Rle.Rdash.method}
\aliasA{as.factor,Rle-method}{Rle-class}{as.factor,Rle.Rdash.method}
\aliasA{as.integer,Rle-method}{Rle-class}{as.integer,Rle.Rdash.method}
\aliasA{as.logical,Rle-method}{Rle-class}{as.logical,Rle.Rdash.method}
\aliasA{as.numeric,Rle-method}{Rle-class}{as.numeric,Rle.Rdash.method}
\aliasA{as.raw,Rle-method}{Rle-class}{as.raw,Rle.Rdash.method}
\aliasA{as.vector,Rle,missing-method}{Rle-class}{as.vector,Rle,missing.Rdash.method}
\aliasA{c,Rle-method}{Rle-class}{c,Rle.Rdash.method}
\aliasA{chartr,ANY,ANY,Rle-method}{Rle-class}{chartr,ANY,ANY,Rle.Rdash.method}
\aliasA{class:Rle}{Rle-class}{class:Rle}
\aliasA{coerce,character,Rle-method}{Rle-class}{coerce,character,Rle.Rdash.method}
\aliasA{coerce,complex,Rle-method}{Rle-class}{coerce,complex,Rle.Rdash.method}
\aliasA{coerce,factor,Rle-method}{Rle-class}{coerce,factor,Rle.Rdash.method}
\aliasA{coerce,integer,Rle-method}{Rle-class}{coerce,integer,Rle.Rdash.method}
\aliasA{coerce,logical,Rle-method}{Rle-class}{coerce,logical,Rle.Rdash.method}
\aliasA{coerce,numeric,Rle-method}{Rle-class}{coerce,numeric,Rle.Rdash.method}
\aliasA{coerce,raw,Rle-method}{Rle-class}{coerce,raw,Rle.Rdash.method}
\aliasA{coerce,Rle,character-method}{Rle-class}{coerce,Rle,character.Rdash.method}
\aliasA{coerce,Rle,complex-method}{Rle-class}{coerce,Rle,complex.Rdash.method}
\aliasA{coerce,Rle,data.frame-method}{Rle-class}{coerce,Rle,data.frame.Rdash.method}
\aliasA{coerce,Rle,factor-method}{Rle-class}{coerce,Rle,factor.Rdash.method}
\aliasA{coerce,Rle,integer-method}{Rle-class}{coerce,Rle,integer.Rdash.method}
\aliasA{coerce,Rle,IRanges-method}{Rle-class}{coerce,Rle,IRanges.Rdash.method}
\aliasA{coerce,Rle,logical-method}{Rle-class}{coerce,Rle,logical.Rdash.method}
\aliasA{coerce,Rle,NormalIRanges-method}{Rle-class}{coerce,Rle,NormalIRanges.Rdash.method}
\aliasA{coerce,Rle,numeric-method}{Rle-class}{coerce,Rle,numeric.Rdash.method}
\aliasA{coerce,Rle,raw-method}{Rle-class}{coerce,Rle,raw.Rdash.method}
\aliasA{coerce,Rle,vector-method}{Rle-class}{coerce,Rle,vector.Rdash.method}
\aliasA{coerce,vector,Rle-method}{Rle-class}{coerce,vector,Rle.Rdash.method}
\aliasA{Complex,Rle-method}{Rle-class}{Complex,Rle.Rdash.method}
\aliasA{cor,Rle,Rle-method}{Rle-class}{cor,Rle,Rle.Rdash.method}
\aliasA{cov,Rle,Rle-method}{Rle-class}{cov,Rle,Rle.Rdash.method}
\aliasA{diff,Rle-method}{Rle-class}{diff,Rle.Rdash.method}
\aliasA{end,Rle-method}{Rle-class}{end,Rle.Rdash.method}
\aliasA{findRange}{Rle-class}{findRange}
\aliasA{findRange,Rle-method}{Rle-class}{findRange,Rle.Rdash.method}
\aliasA{findRun}{Rle-class}{findRun}
\aliasA{findRun,Rle-method}{Rle-class}{findRun,Rle.Rdash.method}
\aliasA{gsub,ANY,ANY,Rle-method}{Rle-class}{gsub,ANY,ANY,Rle.Rdash.method}
\aliasA{IQR,Rle-method}{Rle-class}{IQR,Rle.Rdash.method}
\aliasA{is.na,Rle-method}{Rle-class}{is.na,Rle.Rdash.method}
\aliasA{is.unsorted,Rle-method}{Rle-class}{is.unsorted,Rle.Rdash.method}
\aliasA{length,Rle-method}{Rle-class}{length,Rle.Rdash.method}
\aliasA{levels,Rle-method}{Rle-class}{levels,Rle.Rdash.method}
\aliasA{levels<-,Rle-method}{Rle-class}{levels<.Rdash.,Rle.Rdash.method}
\aliasA{mad,Rle-method}{Rle-class}{mad,Rle.Rdash.method}
\aliasA{match,Rle,ANY-method}{Rle-class}{match,Rle,ANY.Rdash.method}
\aliasA{Math,Rle-method}{Rle-class}{Math,Rle.Rdash.method}
\aliasA{Math2,Rle-method}{Rle-class}{Math2,Rle.Rdash.method}
\aliasA{mean,Rle-method}{Rle-class}{mean,Rle.Rdash.method}
\aliasA{median,Rle-method}{Rle-class}{median,Rle.Rdash.method}
\aliasA{nchar,Rle-method}{Rle-class}{nchar,Rle.Rdash.method}
\aliasA{nrun}{Rle-class}{nrun}
\aliasA{nrun,Rle-method}{Rle-class}{nrun,Rle.Rdash.method}
\aliasA{Ops,Rle,Rle-method}{Rle-class}{Ops,Rle,Rle.Rdash.method}
\aliasA{Ops,Rle,vector-method}{Rle-class}{Ops,Rle,vector.Rdash.method}
\aliasA{Ops,vector,Rle-method}{Rle-class}{Ops,vector,Rle.Rdash.method}
\aliasA{paste}{Rle-class}{paste}
\aliasA{paste,Rle-method}{Rle-class}{paste,Rle.Rdash.method}
\aliasA{pmax}{Rle-class}{pmax}
\aliasA{pmax,Rle-method}{Rle-class}{pmax,Rle.Rdash.method}
\aliasA{pmax.int}{Rle-class}{pmax.int}
\aliasA{pmax.int,Rle-method}{Rle-class}{pmax.int,Rle.Rdash.method}
\aliasA{pmin}{Rle-class}{pmin}
\aliasA{pmin,Rle-method}{Rle-class}{pmin,Rle.Rdash.method}
\aliasA{pmin.int}{Rle-class}{pmin.int}
\aliasA{pmin.int,Rle-method}{Rle-class}{pmin.int,Rle.Rdash.method}
\aliasA{quantile,Rle-method}{Rle-class}{quantile,Rle.Rdash.method}
\aliasA{rep,Rle-method}{Rle-class}{rep,Rle.Rdash.method}
\aliasA{rep.int,Rle-method}{Rle-class}{rep.int,Rle.Rdash.method}
\aliasA{rev,Rle-method}{Rle-class}{rev,Rle.Rdash.method}
\aliasA{Rle}{Rle-class}{Rle}
\aliasA{Rle,missing,missing-method}{Rle-class}{Rle,missing,missing.Rdash.method}
\aliasA{Rle,vectorORfactor,integer-method}{Rle-class}{Rle,vectorORfactor,integer.Rdash.method}
\aliasA{Rle,vectorORfactor,missing-method}{Rle-class}{Rle,vectorORfactor,missing.Rdash.method}
\aliasA{Rle,vectorORfactor,numeric-method}{Rle-class}{Rle,vectorORfactor,numeric.Rdash.method}
\aliasA{runLength}{Rle-class}{runLength}
\aliasA{runLength,Rle-method}{Rle-class}{runLength,Rle.Rdash.method}
\aliasA{runLength<\Rdash}{Rle-class}{runLength<.Rdash.}
\aliasA{runLength<-,Rle-method}{Rle-class}{runLength<.Rdash.,Rle.Rdash.method}
\aliasA{runmean,Rle-method}{Rle-class}{runmean,Rle.Rdash.method}
\aliasA{runmed,Rle-method}{Rle-class}{runmed,Rle.Rdash.method}
\aliasA{runq,Rle-method}{Rle-class}{runq,Rle.Rdash.method}
\aliasA{runsum,Rle-method}{Rle-class}{runsum,Rle.Rdash.method}
\aliasA{runValue}{Rle-class}{runValue}
\aliasA{runValue,Rle-method}{Rle-class}{runValue,Rle.Rdash.method}
\aliasA{runValue<\Rdash}{Rle-class}{runValue<.Rdash.}
\aliasA{runValue<-,Rle-method}{Rle-class}{runValue<.Rdash.,Rle.Rdash.method}
\aliasA{runwtsum,Rle-method}{Rle-class}{runwtsum,Rle.Rdash.method}
\aliasA{sd,Rle-method}{Rle-class}{sd,Rle.Rdash.method}
\aliasA{seqselect,Rle-method}{Rle-class}{seqselect,Rle.Rdash.method}
\aliasA{seqselect<-,Rle-method}{Rle-class}{seqselect<.Rdash.,Rle.Rdash.method}
\aliasA{shiftApply,Rle,Rle-method}{Rle-class}{shiftApply,Rle,Rle.Rdash.method}
\aliasA{show,Rle-method}{Rle-class}{show,Rle.Rdash.method}
\aliasA{smoothEnds,Rle-method}{Rle-class}{smoothEnds,Rle.Rdash.method}
\aliasA{sort,Rle-method}{Rle-class}{sort,Rle.Rdash.method}
\aliasA{split,Rle-method}{Rle-class}{split,Rle.Rdash.method}
\aliasA{splitRanges}{Rle-class}{splitRanges}
\aliasA{splitRanges,Rle-method}{Rle-class}{splitRanges,Rle.Rdash.method}
\aliasA{splitRanges,vectorORfactor-method}{Rle-class}{splitRanges,vectorORfactor.Rdash.method}
\aliasA{start,Rle-method}{Rle-class}{start,Rle.Rdash.method}
\aliasA{sub,ANY,ANY,Rle-method}{Rle-class}{sub,ANY,ANY,Rle.Rdash.method}
\aliasA{substr,Rle-method}{Rle-class}{substr,Rle.Rdash.method}
\aliasA{substring,Rle-method}{Rle-class}{substring,Rle.Rdash.method}
\aliasA{Summary,Rle-method}{Rle-class}{Summary,Rle.Rdash.method}
\aliasA{summary,Rle-method}{Rle-class}{summary,Rle.Rdash.method}
\aliasA{table}{Rle-class}{table}
\aliasA{table,Rle-method}{Rle-class}{table,Rle.Rdash.method}
\aliasA{tolower,Rle-method}{Rle-class}{tolower,Rle.Rdash.method}
\aliasA{toupper,Rle-method}{Rle-class}{toupper,Rle.Rdash.method}
\aliasA{unique,Rle-method}{Rle-class}{unique,Rle.Rdash.method}
\aliasA{var,Rle,missing-method}{Rle-class}{var,Rle,missing.Rdash.method}
\aliasA{var,Rle,Rle-method}{Rle-class}{var,Rle,Rle.Rdash.method}
\aliasA{which,Rle-method}{Rle-class}{which,Rle.Rdash.method}
\aliasA{width,Rle-method}{Rle-class}{width,Rle.Rdash.method}
\aliasA{window,Rle-method}{Rle-class}{window,Rle.Rdash.method}
\aliasA{[,Rle-method}{Rle-class}{[,Rle.Rdash.method}
\aliasA{[<-,Rle-method}{Rle-class}{[<.Rdash.,Rle.Rdash.method}
\aliasA{\%in\%,Rle,ANY-method}{Rle-class}{.Rpcent.in.Rpcent.,Rle,ANY.Rdash.method}
\keyword{methods}{Rle-class}
\keyword{classes}{Rle-class}
\begin{Description}\relax
The Rle class is a general container for storing an atomic vector
that is stored in a run-length encoding format. It is based on the
\code{\LinkA{rle}{rle}} function from the base package.
\end{Description}
\begin{Section}{Constructors}
\describe{
\item[] \code{Rle(values)}:
This constructor creates an Rle instances out of an atomic
vector \code{values}.

\item[] \code{Rle(values, lengths)}:
This constructor creates an Rle instances out of an atomic
vector or factor object \code{values} and an integer or numeric vector
\code{lengths} with all positive elements that represent how many times
each value is repeated. The length of these two vectors must be the same.

\item[] \code{as(from, "Rle")}:
This constructor creates an Rle instances out of an atomic
vector \code{from}.

}
\end{Section}
\begin{Section}{Accessors}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{runLength(x)}:
Returns the run lengths for \code{x}.

\item[] \code{runValue(x)}:
Returns the run values for \code{x}.

\item[] \code{nrun(x)}:
Returns the number of runs in \code{x}.

\item[] \code{start(x)}:
Returns the starts of the runs for \code{x}.

\item[] \code{end(x)}:
Returns the ends of the runs for \code{x}.

\item[] \code{width(x)}:
Same as \code{runLength(x)}.

}
\end{Section}
\begin{Section}{Replacers}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{runLength(x) <- value}:
Replaces \code{x} with a new Rle object using run values
\code{runValue(x)} and run lengths \code{value}.

\item[] \code{runValue(x) <- value}:
Replaces \code{x} with a new Rle object using run values
\code{value} and run lengths \code{runLength(x)}.

}
\end{Section}
\begin{Section}{Coercion}
In the code snippets below, \code{x} and \code{from} are Rle objects:

\describe{
\item[] \code{as.vector(x)}, \code{as(from, "vector")}: Creates an atomic vector
of the most appropriate type based on the values contained in \code{x}.

\item[] \code{as.logical(x)}, \code{as(from, "logical")}: Creates a logical
vector based on the values contained in \code{x}.

\item[] \code{as.integer(x)}, \code{as(from, "integer")}: Creates an integer
vector based on the values contained in \code{x}.

\item[] \code{as.numeric(x)}, \code{as(from, "numeric")}: Creates a numeric
vector based on the values contained in \code{x}.

\item[] \code{as.complex(x)}, \code{as(from, "complex")}: Creates a complex
vector based on the values contained in \code{x}.

\item[] \code{as.character(x)}, \code{as(from, "character")}: Creates a character
vector based on the values contained in \code{x}.

\item[] \code{as.raw(x)}, \code{as(from, "raw")}: Creates a raw
vector based on the values contained in \code{x}.

\item[] \code{as.factor(x)}, \code{as(from, "factor")}: Creates a factor object
based on the values contained in \code{x}.

\item[] \code{as.data.frame(x)}, \code{as(from, "data.frame")}: Creates
a \code{data.frame} with a single column holding the result of
\code{as.vector(x)}.

\item[] \code{as(from, "IRanges")}: Creates an \LinkA{IRanges}{IRanges} instance
from a logical Rle. Note that this instance is guaranteed to be normal.

\item[] \code{as(from, "NormalIRanges")}: Creates a \LinkA{NormalIRanges}{NormalIRanges} instance
from a logical Rle.

}
\end{Section}
\begin{Section}{Group Generics}
Rle objects have support for S4 group generic functionality:
\describe{
\item[\code{Arith}] \code{"+"}, \code{"-"}, \code{"*"}, \code{"\textasciicircum{}"},
\code{"\%\%"}, \code{"\%/\%"}, \code{"/"}
\item[\code{Compare}] \code{"=="}, \code{">"}, \code{"<"}, \code{"!="}, 
\code{"<="}, \code{">="}
\item[\code{Logic}] \code{"\&"}, \code{"|"}
\item[\code{Ops}] \code{"Arith"}, \code{"Compare"}, \code{"Logic"}
\item[\code{Math}] \code{"abs"}, \code{"sign"}, \code{"sqrt"},
\code{"ceiling"}, \code{"floor"}, \code{"trunc"}, \code{"cummax"},
\code{"cummin"}, \code{"cumprod"}, \code{"cumsum"}, \code{"log"},
\code{"log10"}, \code{"log2"}, \code{"log1p"}, \code{"acos"},
\code{"acosh"}, \code{"asin"}, \code{"asinh"}, \code{"atan"},
\code{"atanh"}, \code{"exp"}, \code{"expm1"}, \code{"cos"},
\code{"cosh"}, \code{"sin"}, \code{"sinh"}, \code{"tan"}, \code{"tanh"},
\code{"gamma"}, \code{"lgamma"}, \code{"digamma"}, \code{"trigamma"}
\item[\code{Math2}] \code{"round"}, \code{"signif"}
\item[\code{Summary}] \code{"max"}, \code{"min"}, \code{"range"},
\code{"prod"}, \code{"sum"}, \code{"any"}, \code{"all"}
\item[\code{Complex}] \code{"Arg"}, \code{"Conj"}, \code{"Im"},
\code{"Mod"}, \code{"Re"}
}
See \LinkA{S4groupGeneric}{S4groupGeneric} for more details.
\end{Section}
\begin{Section}{General Methods}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{x[i, drop = !is.null(getOption("dropRle")) \&\& getOption("dropRle")]}:
Subsets \code{x} by index \code{i}, where \code{i} can be positive
integers, negative integers, a logical vector of the same length as
\code{x}, an Rle object of the same length as \code{x}
containing logical values, or an \LinkA{IRanges}{IRanges} object.
When \code{drop = FALSE} returns an Rle object. When \code{drop = TRUE},
returns an atomic vector.

\item[] \code{x[i] <- value}:
Equivalent to \code{seqselect(x, i) <- value}.

\item[] \code{x \%in\% table}:
Returns a logical Rle representing set membership in
\code{table}.

\item[] \code{aggregate(x, by, FUN, start = NULL, end = NULL, width = NULL,
                      frequency = NULL, delta = NULL, ..., simplify = TRUE))}:
Generates summaries on the specified windows and returns the result in a
convenient form:
\describe{
\item[\code{by}] An object with \code{start}, \code{end}, and
\code{width} methods.
\item[\code{FUN}] The function, found via \code{match.fun}, to be
applied to each window of \code{x}.
\item[\code{start}, \code{end}, \code{width}] the start, end, or width
of the window. If \code{by} is missing, then must supply two of the
three.
\item[\code{frequency}, \code{delta}] Optional arguments that specify
the sampling frequency and increment within the window.
\item[\dots] Further arguments for \code{FUN}.
\item[\code{simplify}] A logical value specifying whether or not the
result should be simplified to a vector or matrix if possible.
}

\item[] \code{append(x, values, after = length(x))}:
Insert one Rle into another Rle.
\describe{
\item[\code{values}] the Rle to insert.
\item[\code{after}] the subscript in \code{x} after which the values
are to be inserted.
}

\item[] \code{c(x, ...)}:
Combines a set of Rle objects.

\item[] \code{findRange(x, vec)}:
Returns an \LinkA{IRanges}{IRanges} object representing the ranges in Rle \code{vec}
that are referenced by the indices in the integer vector \code{x}.

\item[] \code{findRun(x, vec)}:
Returns an integer vector indicating the run indices in Rle \code{vec}
that are referenced by the indices in the integer vector \code{x}.

\item[] \code{head(x, n = 6L)}:
If \code{n} is non-negative, returns the first n elements of \code{x}.
If \code{n} is negative, returns all but the last \code{abs(n)} elements
of \code{x}.

\item[] \code{is.na(x)}:
Returns a logical Rle indicating with values are \code{NA}.

\item[] \code{is.unsorted(x, na.rm = FALSE, strictly = FALSE)}:
Returns a logical value specifying if \code{x} is unsorted.
\describe{
\item[\code{na.rm}] remove missing values from check.
\item[\code{strictly}] check for _strictly_ increasing values.
}

\item[] \code{length(x)}:
Returns the underlying vector length of \code{x}.

\item[] \code{match(x, table, nomatch = NA\_integer\_, incomparables = NULL)}:
Matches the values in \code{x} to \code{table}:
\describe{
\item[\code{table}] the values to be matched against.
\item[\code{nomatch}] the value to be returned in the case when no
match is found.
\item[\code{incomparables}] a vector of values that cannot be matched.
Any value in \code{x} matching a value in this vector is assigned
the \code{nomatch} value.
}

\item[] \code{rep(x, times, length.out, each)}, \code{rep.int(x, times)}:
Repeats the values in \code{x} through one of the following conventions:
\describe{
\item[\code{times}] Vector giving the number of times to repeat each
element if of length \code{length(x)}, or to repeat the whole vector
if of length 1.
\item[\code{length.out}] Non-negative integer. The desired length of
the output vector.
\item[\code{each}] Non-negative integer.  Each element of \code{x} is
repeated \code{each} times.
}

\item[] \code{rev(x)}:
Reverses the order of the values in \code{x}.

\item[] \code{seqselect(x, start = NULL, end = NULL, width = NULL)}:
Creates a new Rle object using consecutive subsequences from \code{x}
specified by two of the three following values:  \code{start}, \code{end},
and \code{width}. See \LinkA{seqselect}{seqselect} for more details.

\item[] \code{seqselect(x, start=NULL, end=NULL, width=NULL) <- value}:
Similar to \code{window<-}, except that multiple consecutive subsequences
can be replaced by a constant \code{value}. As such two of the three
\code{start}, \code{end}, and \code{width} arguments can be used to
specify the consecutive subsequences. Alternatively, \code{start} can take
a Ranges object or something that can be converted to a Ranges object like
an integer vector, logical vector or logical Rle.

\item[] \code{shiftApply(SHIFT, X, Y, FUN, ..., OFFSET = 0L, simplify = TRUE, verbose = FALSE)}:
Let \code{i} be the indices in \code{SHIFT},
\code{X\_i = window(X, 1 + OFFSET, length(X) - SHIFT[i])}, and
\code{Y\_i = window(Y, 1 + SHIFT[i], length(Y) - OFFSET)}. Calculates
the set of \code{FUN(X\_i, Y\_i, ...)} values and return the results in a
convenient form:
\describe{
\item[\code{SHIFT}] A non-negative integer vector of shift values.
\item[\code{X}, \code{Y}] The Rle objects to shift.
\item[\code{FUN}] The function, found via \code{match.fun}, to be
applied to each set of shifted vectors.
\item[\dots] Further arguments for \code{FUN}.
\item[OFFSET] A non-negative integer offset to maintain throughout
the shift operations.
\item[\code{simplify}] A logical value specifying whether or not the
result should be simplified to a vector or matrix if possible.
\item[\code{verbose}] A logical value specifying whether or not to
print the \code{i} indices to track the iterations.
}

\item[] \code{show(object)}:
Prints out the Rle object in a user-friendly way.

\item[] \code{sort(x, decreasing = FALSE, na.last = NA)}:
Sorts the values in \code{x}.
\describe{
\item[\code{decreasing}] If \code{TRUE}, sort values in decreasing
order. If \code{FALSE}, sort values in increasing order.
\item[\code{na.last}] If \code{TRUE}, missing values are placed last.
If \code{FALSE}, they are placed first. If \code{NA}, they are
removed.
}

\item[] \code{split(x, f, drop = FALSE)}:
Splits \code{x} according to \code{f} to create a
\LinkA{CompressedRleList}{CompressedRleList.Rdash.class} object. Empty list elements are removed
if \code{drop} is \code{TRUE}.

\item[] \code{splitRanges(x)}:
Returns a \LinkA{CompressedIRangesList}{CompressedIRangesList.Rdash.class} object that contain the
ranges for each of the unique run values. 

\item[] \code{subset(x, subset)}:
Returns a new Rle object made of the subset using logical vector
\code{subset}.

\item[] \code{summary(object, ..., digits = max(3, getOption("digits") - 3))}:
Summarizes the Rle object using an atomic vector convention. The
\code{digits} argument is used for number formatting with
\code{signif()}.

\item[] \code{table(...)}:
Returns a table containing the counts of the unique values.

\item[] \code{tail(x, n = 6L)}:
If \code{n} is non-negative, returns the last n elements of \code{x}.
If \code{n} is negative, returns all but the first \code{abs(n)} elements
of \code{x}.

\item[] \code{unique(x, incomparables = FALSE, ...)}:
Returns the unique run values. The \code{incomparables} argument takes a
vector of values that cannot be compared with \code{FALSE} being a special
value that means that all values can be compared. 

\item[] \code{window(x, start = NA, end = NA, width = NA, frequency = NULL, delta = NULL, ...)}:
Extract the subsequence window from \code{x} specified by:
\describe{
\item[\code{start}, \code{end}, \code{width}] The start, end, or width
of the window. Two of the three are required.
\item[\code{frequency}, \code{delta}] Optional arguments that specify
the sampling frequency and increment within the window.
}

\item[] \code{window(x, start = NA, end = NA, width = NA, keepLength = TRUE) <- value}:
Replace the subsequence window specified on the left (i.e. the subsequence
in \code{x} specified by \code{start}, \code{end} and \code{width})
by \code{value}.
\code{value} must either be of class Rle, belong to a subclass of Rle, be
coercible to Rle, or be \code{NULL}.
If \code{keepLength} is \code{TRUE}, the elements of \code{value} are
repeated to create an Rle with the same number of elements as the
width of the subsequence window it is replacing.
If \code{keepLength} is \code{FALSE}, this replacement method can modify
the length of \code{x}, depending on how the length of the left
subsequence window compares to the length of \code{value}.

}
\end{Section}
\begin{Section}{Logical Data Methods}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{!x}:
Returns logical negation (NOT) of \code{x}.

\item[] \code{which(x)}:
Returns an integer vector representing the \code{TRUE} indices of
\code{x}.

}
\end{Section}
\begin{Section}{Numerical Data Methods}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{diff(x, lag = 1, differences = 1}:
Returns suitably lagged and iterated differences of \code{x}.
\describe{
\item[\code{lag}] An integer indicating which lag to use.
\item[\code{differences}] An integer indicating the order of the
difference.
}

\item[] \code{pmax(..., na.rm = FALSE)}, \code{pmax.int(..., na.rm = FALSE)}:
Parallel maxima of the Rle input values. Removes \code{NA}s when
\code{na.rm = TRUE}.

\item[] \code{pmin(..., na.rm = FALSE)}, \code{pmin.int(..., na.rm = FALSE)}:
Parallel minima of the Rle input values. Removes \code{NA}s when
\code{na.rm = TRUE}.

\item[] \code{mean(x, na.rm = FALSE)}:
Calculates the mean of \code{x}. Removes \code{NA}s when
\code{na.rm = TRUE}.

\item[] \code{var(x, y = NULL, na.rm = FALSE)}:
Calculates the variance of \code{x} or covariance of \code{x} and \code{y}
if both are supplied. Removes \code{NA}s when \code{na.rm = TRUE}.

\item[] \code{cov(x, y, use = "everything")}, \code{cor(x, y, use = "everything")}:
Calculates the covariance and correlation respectively of Rle objects
\code{x} and \code{y}.
The \code{use} argument is an optional character string giving a method for
computing covariances in the presence of missing values. This must be
(an abbreviation of) one of the strings \code{"everything"},
\code{"all.obs"}, \code{"complete.obs"}, \code{"na.or.complete"}, or
\code{"pairwise.complete.obs"}.

\item[] \code{sd(x, na.rm = FALSE)}:
Calculates the standard deviation of \code{x}. Removes \code{NA}s
when \code{na.rm = TRUE}.

\item[] \code{median(x, na.rm = FALSE)}:
Calculates the median of \code{x}. Removes \code{NA}s when
\code{na.rm = TRUE}.

\item[] \code{quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type = 7, ...)}:
Calculates the specified quantiles of \code{x}.
\describe{
\item[\code{probs}] A numeric vector of probabilities with values in
[0,1].
\item[\code{na.rm}] If \code{TRUE}, removes \code{NA}s from \code{x}
before the quantiles are computed.
\item[\code{names}] If \code{TRUE}, the result has names describing the
quantiles.
\item[\code{type}] An integer between 1 and 9 selecting one of the nine
quantile algorithms detailed in \code{\LinkA{quantile}{quantile}}.
\item[\dots] Further arguments passed to or from other methods.
}

\item[] \code{mad(x, center = median(x), constant = 1.4826, na.rm = FALSE, low = FALSE, high = FALSE)}:
Calculates the median absolute deviation of \code{x}.
\describe{
\item[\code{center}] The center to calculate the deviation from.
\item[\code{constant}] The scale factor.
\item[\code{na.rm}] If \code{TRUE}, removes \code{NA}s from \code{x}
before the mad is computed.
\item[\code{low}] If \code{TRUE}, compute the 'lo-median'.
\item[\code{high}] If \code{TRUE}, compute the 'hi-median'.
}

\item[] \code{IQR(x, na.rm = FALSE)}:
Calculates the interquartile range of \code{x}.
\describe{
\item[\code{na.rm}] If \code{TRUE}, removes \code{NA}s from \code{x}
before the IQR is computed.
}

\item[] \code{smoothEnds(y, k = 3)}:
Smooth end points of an Rle \code{y} using subsequently smaller
medians and Tukey's end point rule at the very end.
\describe{
\item[\code{k}] An integer indicating the width of largest median
window; must be odd.
}

\item[] \code{runmean(x, k, endrule = c("drop", "constant"))}:
Calculates the means for fixed width running windows across \code{x}.
\describe{
\item[\code{k}] An integer indicating the fixed width of the running
window. Must be odd when \code{endrule == "constant"}.
\item[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};
}

}

\item[] \code{runmed(x, k, endrule = c("median", "keep", "drop", "constant"))}:
Calculates the medians for fixed width running windows across \code{x}.
\describe{
\item[\code{k}] An integer indicating the fixed width of the running
window. Must be odd when \code{endrule != "drop"}.
\item[endrule] A character string indicating how the values at the
beginning and the end (of the data) should be treated.
\describe{
\item[\code{"keep"}] keeps the first and last \eqn{k_2}{k2}
values at both ends, where \eqn{k_2}{k2} is the half-bandwidth
\code{k2 = k \%/\% 2}, i.e., \code{y[j] = x[j]} for
\eqn{j \in \{1,\ldots,k_2; n-k_2+1,\ldots,n\}}{}
{j = 1,..,k2 and (n-k2+1),..,n};
\item[\code{"constant"}] copies the running statistic to the
first values and analogously for the last ones making the
smoothed ends \emph{constant};
\item[\code{"median"}] the default, smooths the ends by using
symmetrical medians of subsequently smaller bandwidth, but
for the very first and last value where Tukey's robust
end-point rule is applied, see \code{\LinkA{smoothEnds}{smoothEnds}}.
}

}

\item[] \code{runsum(x, k, endrule = c("drop", "constant"))}:
Calculates the sums for fixed width running windows across \code{x}.
\describe{
\item[\code{k}] An integer indicating the fixed width of the running
window. Must be odd when \code{endrule == "constant"}.
\item[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};
}

}

\item[] \code{runwtsum(x, k, wt, endrule = c("drop", "constant"))}:
Calculates the sums for fixed width running windows across \code{x}.
\describe{
\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[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};
}

}

\item[] \code{runq(x, k, i, endrule = c("drop", "constant"))}:
Calculates the order statistic for fixed width running windows across
\code{x}.
\describe{
\item[\code{k}] An integer indicating the fixed width of the running
window. Must be odd when \code{endrule == "constant"}.
\item[\code{i}] An integer indicating which order statistic to
calculate.
\item[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{Section}
\begin{Section}{Character Data Methods}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{nchar(x, type = "chars", allowNA = FALSE)}:
Returns an integer Rle representing the number of characters in the
corresponding values of \code{x}.
\describe{
\item[\code{type}] One of \code{c("bytes", "chars", "width")}.
\item[\code{allowNA}] Should \code{NA} be returned for invalid multibyte
strings rather than throwing an error?
}

\item[] \code{substr(x, start, stop)}, \code{substring(text, first, last = 1000000L)}:
Returns a character or factor Rle containing the specified substrings
beginning at \code{start}/\code{first} and ending at
\code{stop}/\code{last}.

\item[] \code{chartr(old, new, x)}:
Returns a character or factor Rle containing a translated version of
\code{x}.
\describe{
\item[\code{old}] A character string specifying the characters to be
translated.
\item[\code{new}] A character string specifying the translations.
}

\item[] \code{tolower(x)}:
Returns a character or factor Rle containing a lower case version of
\code{x}.

\item[] \code{toupper(x)}:
Returns a character or factor Rle containing an upper case version of
\code{x}.

\item[] \code{sub(pattern, replacement, x, ignore.case = FALSE,
                perl = FALSE, fixed = FALSE, useBytes = FALSE)}:
Returns a character or factor Rle containing replacements based on
matches determined by regular expression matching. See \code{\LinkA{sub}{sub}}
for a description of the arguments.

\item[] \code{gsub(pattern, replacement, x, ignore.case = FALSE,
                 perl = FALSE, fixed = FALSE, useBytes = FALSE)}:
Returns a character or factor Rle containing replacements based on
matches determined by regular expression matching. See \code{\LinkA{gsub}{gsub}}
for a description of the arguments.

\item[] \code{paste(..., sep = " ", collapse = NULL)}:
Returns a character or factor Rle containing a concatenation of
the values in \code{...}.

}
\end{Section}
\begin{Section}{Factor Data Methods}
In the code snippets below, \code{x} is an Rle object:

\describe{
\item[] \code{levels(x)}, \code{levels(x) <- value}:
Gets and sets the factor levels, respectively.

\item[] \code{nlevels(x)}:
Returns the number of factor levels.

}
\end{Section}
\begin{Author}\relax
P. Aboyoun
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{rle}{rle}},
\LinkA{Sequence-class}{Sequence.Rdash.class},
\LinkA{S4groupGeneric}{S4groupGeneric},
\LinkA{IRanges-class}{IRanges.Rdash.class}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  x <- Rle(10:1, 1:10)
  x

  runLength(x)
  runValue(x)
  nrun(x)

  diff(x)
  unique(x)
  sort(x)
  sqrt(x)
  x^2 + 2 * x + 1
  x[c(1,3,5,7,9)]
  window(x, 4, 14)
  range(x)
  table(x)
  sum(x)
  mean(x)
  x > 4
  aggregate(x, x > 4, mean)
  aggregate(x, FUN = mean, start = 1:(length(x) - 50), end = 51:length(x))

  y <- Rle(c(TRUE,TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE))
  y
  as.vector(y)
  rep(y, 10)
  c(y, x > 5)

  z <- c("the", "quick", "red", "fox", "jumps", "over", "the", "lazy", "brown", "dog")
  z <- Rle(z, seq_len(length(z)))
  chartr("a", "@", z)
  toupper(z)
\end{ExampleCode}
\end{Examples}

