cs0815 cs0815 - 3 years ago 145
R Question

differencing time series using diff in r

Looking at this what does:

diff(SomeTimeSeries)


do? Does it by default do:

diff(SomeTimeSeries, differences = 1)


Or does it use ndiff to define the correct value for differences?

Answer Source

By looking at the Usage section of the diff help file (?diff), you can see that, yes, by default differences argument is set to 1. This "works" for every single function in R.

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, ...)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download