\Header{diff}{Lagged Differences}
\alias{diff.default}{diff}
\keyword{ts}{diff}
\keyword{arith}{diff}
\begin{Usage}
\begin{verbatim}
diff(x, ...)
diff.default(x, lag=1, differences=1)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] a numeric vector or matrix containing the values to be differenced.
\item[\texttt{lag}] an integer indicating which lag to use.
\item[\texttt{differences}] an integer indicating the order of the difference.
\end{ldescription}
\end{Arguments}
\begin{Value}
If \texttt{x} is a vector of length \texttt{n} and \texttt{differences=1},
then the computed result is equal to the successive differences
\texttt{x[(1:n-lag)]-x[(lag:n)]}.
If \texttt{difference} is larger than one this
algorithm is applied recursively to \texttt{x}. Note that the returned value
is a vector which is shorter than \texttt{x}.

If \texttt{x} is a matrix then the difference operations are carried out
on each column separately.

\texttt{NA}'s propagate.\end{Value}
\begin{Examples}
\begin{ExampleCode}
diff(1:10, 2)
diff(1:10, 2, 2)
\end{ExampleCode}
\end{Examples}

