Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

base-diff

diff


Description

Differences a 'timeSeries' 0bject.

Usage

diff(x, ...)

Arguments

x

an object of class 'timeSeries'.

...

further arguments to be passed. These may include

Details

Arguments to be passed may include:

lag - an integer indicating which lag to use. By default 1.
diff - an integer indicating the order of the difference. By default 1.
trim - a logical flag. Should NAs at the beginning of the series be removed? By default FALSE.
pad - a umeric value with which NAs should be replaced at the beginning of the series. By default NA.

Value

Returns a differenced S4 'timeSeries' object.

Examples

## Load Microsoft Data Set -
   x <- MSFT[1:12, ]
   x

## Compute Differences -
   diff(x)   
   
## Trimmed Differences -
   diff(x, trim=TRUE) 

## Padded Differences -
   diff(x, trim=FALSE, pad=0)

timeSeries

Financial Time Series Objects (Rmetrics)

v3062.100
GPL (>= 2)
Authors
Diethelm Wuertz [aut] (original code), Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb] (<https://orcid.org/0000-0002-8685-9910>)
Initial release
2020-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.