Learn R Programming

xts (version 0.13.1)

periodicity: Approximate Series Periodicity

Description

Estimate the periodicity of a time-series-like object by calculating the median time between observations in days.

Usage

periodicity(x, ...)

Value

An object containing a list containing the difftime object, frequency, units, and suitable scale.

Arguments

x

time-series-like object

...

unused

Author

Jeffrey A. Ryan

Details

A simple wrapper to quickly estimate the periodicity of a given data. Returning an object of type periodicity.

This calculates the median number of days between observations as a difftime object, the numerical difference, the units of measurement, and the derived scale of the data as a string.

The time index currently must be of either Date or POSIX class, or coercible to such.

The only list item of note is the scale. This is an estimate of the periodicity of the data in common terms - e.g. 7 day daily data is best described as ‘weekly’, and would be returned as such.

Possible scale values are:

‘minute’,‘hourly’, ‘daily’,‘weekly’, ‘monthly’,‘quarterly’, and ‘yearly’.

See Also

Examples

Run this code
zoo.ts <- zoo(rnorm(231),as.Date(13514:13744,origin="1970-01-01"))
periodicity(zoo.ts)

Run the code above in your browser using DataLab