diff {timeSeries}R Documentation

Difference a 'timeSeries' object

Description

Difference a "timeSeries" object.

Usage

## S3 method for class 'timeSeries'
diff(x, lag = 1, diff = 1, trim = FALSE, pad = NA, ...)

Arguments

x

an object of class "timeSeries".

lag

an integer indicating which lag to use.

diff

an integer indicating the order of the difference.

trim

a logical flag. Should NAs at the beginning of the series be removed?

pad

a numeric value with which NAs should be replaced at the beginning of the series.

...

currently not used.

Value

the differenced "timeSeries" object

See Also

diff for ⁠base::diff⁠, lag

Examples

## load Microsoft dataset
x <- MSFT[1:12, ]
x

## compute differences
diff(x)   
   
## trimmed differences
diff(x, trim = TRUE) 

## padded differences
diff(x, trim = FALSE, pad = 0) 

[Package timeSeries version 4032.109 Index]