\HeaderA{seq}{Sequence Generation}{seq}
\methaliasA{seq.default}{seq}{seq.default}
\methaliasA{seq.int}{seq}{seq.int}
\aliasA{seq\_along}{seq}{seq.Rul.along}
\aliasA{seq\_len}{seq}{seq.Rul.len}
\keyword{manip}{seq}
\begin{Description}\relax
Generate regular sequences.  \code{seq} is a standard generic with a
default method.  \code{seq.int} is an internal generic which can be
much faster but has a few restrictions.  \code{seq\_along} and
\code{seq\_len} are very fast primitives for two common cases.
\end{Description}
\begin{Usage}
\begin{verbatim}
seq(...)

## Default S3 method:
seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)),
    length.out = NULL, along.with = NULL, ...)

seq.int(from, to, by, length.out, along.with, ...)

seq_along(along.with)
seq_len(length.out)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] arguments passed to or from methods.
\item[\code{from, to}] the starting and (maximal) end value of the sequence.
\item[\code{by}] number: increment of the sequence.
\item[\code{length.out}] desired length of the sequence.  A
non-negative number, which for \code{seq} and \code{seq.int} will be
rounded up if fractional.
\item[\code{along.with}] take the length from the length of this argument.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The interpretation of the unnamed arguments of \code{seq} and
\code{seq.int} is \emph{not} standard, and it is recommended always to
name the arguments when programming.

Both \code{seq} are \code{seq.int} are generic, and only the default
method is described here.  Typical usages are
\begin{alltt}
seq(from, to)
seq(from, to, by= )
seq(from, to, length.out= )
seq(along.with= )
seq(from)
seq(length.out= )
\end{alltt}
The first form generates the sequence \code{from, from+/-1, ..., to}
(identical to \code{from:to}).

The second form generates \code{from, from+by}, \ldots, up to the
sequence value less than or equal to \code{to}.  Specifying
\code{to - from} and \code{by} of opposite signs is an error.

The third generates a sequence of \code{length.out} equally spaced
values from \code{from} to \code{to}.  (\code{length.out} is usually
abbreviated to \code{length} or \code{len}, and \code{seq\_len} is much
faster.)

The fourth form generates the sequence \code{1, 2, ...,
    length(along.with)}.  (\code{along.with} is usually abbreviated to
\code{along}, and \code{seq\_along} is much faster.) 

The fifth form generates the sequence \code{1, 2, ..., length(from)}
(as if argument \code{along.with} had been specified),
\emph{unless} the argument is numeric of length 1 when it is
interpreted as \code{1:from} (even for \code{seq(0)} for
compatibility with S).

The final form generates \code{1, 2, ..., length.out} unless
\code{length.out = 0}, when it generates \code{integer(0)}.

Very small sequences (with \code{from - to} of the order of \eqn{10^{-14}}{}
times the larger of the ends) will return \code{from}.

For \code{seq}(only), up to two of \code{from}, \code{to} and \code{by} can
be supplied as complex values provided \code{length.out} or
\code{along.with} is specified.
\end{Details}
\begin{Value}
Currently, the default method returns a result of type
\code{"integer"} if \code{from} is (numerically equal to an)
integer and, e.g., only \code{to} is specified, or also if only
\code{length} or only \code{along.with} is specified.  \strong{Note:}
this may change in the future and programmers should not rely on it.
\end{Value}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
The methods \code{\LinkA{seq.Date}{seq.Date}} and \code{\LinkA{seq.POSIXt}{seq.POSIXt}}.

\code{\LinkA{:}{:}},
\code{\LinkA{rep}{rep}},
\code{\LinkA{sequence}{sequence}},
\code{\LinkA{row}{row}},
\code{\LinkA{col}{col}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
seq(0, 1, length=11)
seq(stats::rnorm(20))
seq(1, 9, by = 2) # match
seq(1, 9, by = pi)# stay below
seq(1, 6, by = 3)
seq(1.575, 5.125, by=0.05)
seq(17) # same as 1:17
\end{ExampleCode}
\end{Examples}

