EVOLUTION-MANAGER
Edit File: diff.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Lagged Differences</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for diff {base}"><tr><td>diff {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Lagged Differences</h2> <h3>Description</h3> <p>Returns suitably lagged and iterated differences. </p> <h3>Usage</h3> <pre> diff(x, ...) ## Default S3 method: diff(x, lag = 1, differences = 1, ...) ## S3 method for class 'POSIXt' diff(x, lag = 1, differences = 1, ...) ## S3 method for class 'Date' diff(x, lag = 1, differences = 1, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a numeric vector or matrix containing the values to be differenced.</p> </td></tr> <tr valign="top"><td><code>lag</code></td> <td> <p>an integer indicating which lag to use.</p> </td></tr> <tr valign="top"><td><code>differences</code></td> <td> <p>an integer indicating the order of the difference.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>further arguments to be passed to or from methods.</p> </td></tr> </table> <h3>Details</h3> <p><code>diff</code> is a generic function with a default method and ones for classes <code>"<a href="../../stats/html/ts.html">ts</a>"</code>, <code>"<a href="DateTimeClasses.html">POSIXt</a>"</code> and <code>"<a href="Dates.html">Date</a>"</code>. </p> <p><code><a href="NA.html">NA</a></code>'s propagate. </p> <h3>Value</h3> <p>If <code>x</code> is a vector of length <code>n</code> and <code>differences = 1</code>, then the computed result is equal to the successive differences <code>x[(1+lag):n] - x[1:(n-lag)]</code>. </p> <p>If <code>difference</code> is larger than one this algorithm is applied recursively to <code>x</code>. Note that the returned value is a vector which is shorter than <code>x</code>. </p> <p>If <code>x</code> is a matrix then the difference operations are carried out on each column separately. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="../../stats/html/ts-methods.html">diff.ts</a></code>, <code><a href="../../stats/html/diffinv.html">diffinv</a></code>. </p> <h3>Examples</h3> <pre> diff(1:10, 2) diff(1:10, 2, 2) x <- cumsum(cumsum(1:10)) diff(x, lag = 2) diff(x, differences = 2) diff(.leap.seconds) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>