lag | R Documentation |

Compute a lagged version of a `"timeSeries"`

object.

```
## S4 method for signature 'timeSeries'
lag(x, k = 1, trim = FALSE, units = NULL, ...)
```

`x` |
an object of class |

`k` |
an integer number, the number of lags (in units of observations).
By default 1. Can also be a vector, in which case the result is a
multivariate |

`trim` |
a logical value. By default |

`units` |
an optional character string, which allows to overwrite the current
column names of a |

`...` |
arguments passed to other methods. |

an object of class `"timeSeries"`

`lag`

for `stats::lag`

,
`diff`

```
## Load Micsrosoft Data Set -
x = MSFT[1:20, "Open"]
## Lag the 'timeSeries' Object:
lag(x, k = -1:1)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.